FILE_CLEANER.addFile(source);
if (removeInputFile) FILE_CLEANER.addFile(source);
/** * Delete the specified File. * * @param sourceDirectory the directory to delete files from. * @param filter the {@link FilenameFilter} to use for selecting files to delete. * @param recursive boolean that specifies if we want to delete files recursively or not. * @return */ public static void deleteFile(File file) { inputNotNull(file); if(!file.exists()||!file.canRead()||!file.isFile()) throw new IllegalStateException("Source is not in a legal state."); if(file.delete()) return; IOUtils.FILE_CLEANER.addFile(file); }
/** * Constructor for a {@link FileCleaner}. * * @param period default time period between two cycles. * @param priority is the priority for the cleaner thread. * @param maxattempts maximum number of time the cleaner thread tries to delete a file. */ public FileCleaner(long period, int priority, int maxattempts) { this.period = period; this.setName("FileCleaner"); this.setPriority(priority); this.setDaemon(true); this.maxAttempts = maxattempts; }
/** * Constructor for a {@link FileCleaner}. * * @param period default time period between two cycles. * @param priority is the priority for the cleaner thread. * @param maxattempts maximum number of time the cleaner thread tries to delete a file. */ public FileCleaner(long period, int priority, int maxattempts) { this.period = period; this.setName("FileCleaner"); this.setPriority(priority); this.setDaemon(true); this.maxAttempts = maxattempts; }
/** * Delete the specified File. * * @param file the file to delete */ public static void deleteFile(File file) { inputNotNull(file); if (!file.exists() || !file.canRead() || !file.isFile()) throw new IllegalStateException("Source is not in a legal state."); if (file.delete()) return; IOUtils.FILE_CLEANER.addFile(file); }