/** * Creates a returns a temporary local file/directory with the same extension as the specified * file/directory (guaranteed), and the same filename as much as possible (best effort). This * method returns <code>null</code> if the temporary file/directory could not be created. * * @param nonLocalFile the non-local file for which to create a temporary file. * @return a temporary local file/directory with the same extension as the specified * file/directory */ protected LocalFile createTempLocalFile(AbstractFile nonLocalFile) { try { // Note: the returned temporary file may be an AbstractArchiveFile if the filename's extension // corresponds // to a registered archive format LocalFile tempFile = FileFactory.getTemporaryFile(nonLocalFile.getName(), false).getAncestor(LocalFile.class); // create a directory if (nonLocalFile.isDirectory()) { tempFile.mkdir(); } else { // create a regular file tempFile.getOutputStream().close(); } return tempFile; } catch (IOException e) { return null; } }