@Test public void testTemporaryFiles() throws IOException { String desiredName = System.currentTimeMillis()+".ext"; AbstractFile temporaryFile1 = FileFactory.getTemporaryFile(desiredName, true); assert temporaryFile1 != null; assert !temporaryFile1.exists(); assert desiredName.equals(temporaryFile1.getName()); temporaryFile1.mkfile(); AbstractFile temporaryFile2 = FileFactory.getTemporaryFile(desiredName, true); assert temporaryFile2 != null; assert !temporaryFile2.exists(); assert !temporaryFile2.getName().equals(desiredName); assert temporaryFile1.getExtension().equals(temporaryFile2.getExtension()); temporaryFile1 = FileFactory.getTemporaryFile(true); assert temporaryFile1 != null; assert !temporaryFile1.exists(); }
public static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit) throws IOException { if(desiredFilename==null || desiredFilename.equals("")) desiredFilename = "temp"; AbstractFile tempFile = TEMP_DIRECTORY.getDirectChild(desiredFilename); if(tempFile.exists()) tempFile = TEMP_DIRECTORY.getDirectChild(getFilenameVariation(desiredFilename)); if(deleteOnExit) ((java.io.File)tempFile.getUnderlyingFileObject()).deleteOnExit(); return tempFile; }
FileFactory { public static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit) throws IOException { if(desiredFilename==null || desiredFilename.equals("")) desiredFilename = "temp"; AbstractFile tempFile = TEMP_DIRECTORY.getDirectChild(desiredFilename); if(tempFile.exists()) tempFile = TEMP_DIRECTORY.getDirectChild(getFilenameVariation(desiredFilename)); if(deleteOnExit) ((java.io.File)tempFile.getUnderlyingFileObject()).deleteOnExit(); return tempFile; } }
FileFactory { public static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit) throws IOException { if(desiredFilename==null || desiredFilename.equals("")) desiredFilename = "temp"; AbstractFile tempFile = TEMP_DIRECTORY.getDirectChild(desiredFilename); if(tempFile.exists()) tempFile = TEMP_DIRECTORY.getDirectChild(getFilenameVariation(desiredFilename)); if(deleteOnExit) ((java.io.File)tempFile.getUnderlyingFileObject()).deleteOnExit(); return tempFile; } private  FileFactory(); }
FileFactory { public static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit) throws IOException { if(desiredFilename==null || desiredFilename.equals("")) desiredFilename = "temp"; AbstractFile tempFile = TEMP_DIRECTORY.getDirectChild(desiredFilename); if(tempFile.exists()) tempFile = TEMP_DIRECTORY.getDirectChild(getFilenameVariation(desiredFilename)); if(deleteOnExit) ((java.io.File)tempFile.getUnderlyingFileObject()).deleteOnExit(); return tempFile; } private  FileFactory(); static ProtocolProvider registerProtocol(String protocol, ProtocolProvider provider); static ProtocolProvider unregisterProtocol(String protocol); static ProtocolProvider getProtocolProvider(String protocol); static boolean isRegisteredProtocol(String protocol); static Iterator<String> protocols(); static void registerArchiveFormat(ArchiveFormatProvider provider); static void unregisterArchiveFormat(ArchiveFormatProvider provider); static ArchiveFormatProvider getArchiveFormatProvider(String filename); static List<ArchiveFormatProvider> archiveFormats(); static AbstractFile getFile(String absPath); static AbstractFile getFile(String absPath, boolean throwException); static AbstractFile getFile(String absPath, AbstractFile parent); static AbstractFile getFile(FileURL fileURL); static AbstractFile getFile(FileURL fileURL, boolean throwException); static AbstractFile getFile(FileURL fileURL, AbstractFile parent); static AbstractFile getFile(FileURL fileURL, AbstractFile parent, Map<String, Object> instantiationParams); static AbstractFile getFile(FileURL fileURL, AbstractFile parent, Authenticator authenticator, Map<String, Object> instantiationParams); static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit); static AbstractFile getTemporaryFile(boolean deleteOnExit); static AbstractFile getTemporaryFolder(); static boolean isArchiveFilename(String filename); static AbstractFile wrapArchive(AbstractFile file); static AbstractFile wrapArchive(AbstractFile file, String extension); static FileIconProvider getDefaultFileIconProvider(); static void setDefaultFileIconProvider(FileIconProvider fip); static Authenticator getDefaultAuthenticator(); static void setDefaultAuthenticator(Authenticator authenticator); }
FileFactory { public static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit) throws IOException { if(desiredFilename==null || desiredFilename.equals("")) desiredFilename = "temp"; AbstractFile tempFile = TEMP_DIRECTORY.getDirectChild(desiredFilename); if(tempFile.exists()) tempFile = TEMP_DIRECTORY.getDirectChild(getFilenameVariation(desiredFilename)); if(deleteOnExit) ((java.io.File)tempFile.getUnderlyingFileObject()).deleteOnExit(); return tempFile; } private  FileFactory(); static ProtocolProvider registerProtocol(String protocol, ProtocolProvider provider); static ProtocolProvider unregisterProtocol(String protocol); static ProtocolProvider getProtocolProvider(String protocol); static boolean isRegisteredProtocol(String protocol); static Iterator<String> protocols(); static void registerArchiveFormat(ArchiveFormatProvider provider); static void unregisterArchiveFormat(ArchiveFormatProvider provider); static ArchiveFormatProvider getArchiveFormatProvider(String filename); static List<ArchiveFormatProvider> archiveFormats(); static AbstractFile getFile(String absPath); static AbstractFile getFile(String absPath, boolean throwException); static AbstractFile getFile(String absPath, AbstractFile parent); static AbstractFile getFile(FileURL fileURL); static AbstractFile getFile(FileURL fileURL, boolean throwException); static AbstractFile getFile(FileURL fileURL, AbstractFile parent); static AbstractFile getFile(FileURL fileURL, AbstractFile parent, Map<String, Object> instantiationParams); static AbstractFile getFile(FileURL fileURL, AbstractFile parent, Authenticator authenticator, Map<String, Object> instantiationParams); static AbstractFile getTemporaryFile(String desiredFilename, boolean deleteOnExit); static AbstractFile getTemporaryFile(boolean deleteOnExit); static AbstractFile getTemporaryFolder(); static boolean isArchiveFilename(String filename); static AbstractFile wrapArchive(AbstractFile file); static AbstractFile wrapArchive(AbstractFile file, String extension); static FileIconProvider getDefaultFileIconProvider(); static void setDefaultFileIconProvider(FileIconProvider fip); static Authenticator getDefaultAuthenticator(); static void setDefaultAuthenticator(Authenticator authenticator);  }