一、前言
关于apache的commons-io源码包org.apache.commons.io.FileUtils文件工具类,通过File路径/名称字符串获取文件getFile、获取用户目录getUserDirectoryPath、获取临时路径getTempDirectoryPath、通过文件File打开openOutputStream文件输出流openOutputStream、通过源文件和目标文件进行目录/文件拷贝copyFileToDirectory/copyFile、通过URL源/输入字符流文件拷贝到文件copyURLToFile/copyInputStreamToFile、读取文件为字符串/二进制数组readFileToString/readFileToByteArray等。
二、源码说明package org.apache.commons.io;@b@@b@import java.io.BufferedOutputStream;@b@import java.io.File;@b@import java.io.FileFilter;@b@import java.io.FileInputStream;@b@import java.io.FileNotFoundException;@b@import java.io.FileOutputStream;@b@import java.io.IOException;@b@import java.io.InputStream;@b@import java.io.InputStreamReader;@b@import java.io.OutputStream;@b@import java.io.Reader;@b@import java.math.BigInteger;@b@import java.net.URI;@b@import java.net.URL;@b@import java.net.URLConnection;@b@import java.nio.channels.FileChannel;@b@import java.nio.charset.Charset;@b@import java.util.ArrayList;@b@import java.util.Collection;@b@import java.util.Date;@b@import java.util.Iterator;@b@import java.util.LinkedList;@b@import java.util.List;@b@import java.util.zip.CRC32;@b@import java.util.zip.CheckedInputStream;@b@import java.util.zip.Checksum;@b@import org.apache.commons.io.filefilter.DirectoryFileFilter;@b@import org.apache.commons.io.filefilter.FalseFileFilter;@b@import org.apache.commons.io.filefilter.FileFilterUtils;@b@import org.apache.commons.io.filefilter.IOFileFilter;@b@import org.apache.commons.io.filefilter.SuffixFileFilter;@b@import org.apache.commons.io.filefilter.TrueFileFilter;@b@import org.apache.commons.io.output.NullOutputStream;@b@@b@public class FileUtils@b@{@b@ public static final long ONE_KB = 1024L;@b@ public static final BigInteger ONE_KB_BI = BigInteger.valueOf(1024L);@b@ public static final long ONE_MB = 1048576L;@b@ public static final BigInteger ONE_MB_BI = ONE_KB_BI.multiply(ONE_KB_BI);@b@ private static final long FILE_COPY_BUFFER_SIZE = 31457280L;@b@ public static final long ONE_GB = 1073741824L;@b@ public static final BigInteger ONE_GB_BI = ONE_KB_BI.multiply(ONE_MB_BI);@b@ public static final long ONE_TB = 1099511627776L;@b@ public static final BigInteger ONE_TB_BI = ONE_KB_BI.multiply(ONE_GB_BI);@b@ public static final long ONE_PB = 1125899906842624L;@b@ public static final BigInteger ONE_PB_BI = ONE_KB_BI.multiply(ONE_TB_BI);@b@ public static final long ONE_EB = 1152921504606846976L;@b@ public static final BigInteger ONE_EB_BI = ONE_KB_BI.multiply(ONE_PB_BI);@b@ public static final BigInteger ONE_ZB = BigInteger.valueOf(1024L).multiply(BigInteger.valueOf(1152921504606846976L));@b@ public static final BigInteger ONE_YB = ONE_KB_BI.multiply(ONE_ZB);@b@ public static final File[] EMPTY_FILE_ARRAY = new File[0];@b@ private static final Charset UTF8 = Charset.forName("UTF-8");@b@@b@ public static File getFile(File directory, String[] names)@b@ {@b@ if (directory == null)@b@ throw new NullPointerException("directorydirectory must not be null");@b@@b@ if (names == null)@b@ throw new NullPointerException("names must not be null");@b@@b@ File file = directory;@b@ String[] arr$ = names; int len$ = arr$.length; for (int i$ = 0; i$ 0)@b@ displaySize = String.valueOf(size.divide(ONE_EB_BI)) + " EB";@b@ else if (size.divide(ONE_PB_BI).compareTo(BigInteger.ZERO) > 0)@b@ displaySize = String.valueOf(size.divide(ONE_PB_BI)) + " PB";@b@ else if (size.divide(ONE_TB_BI).compareTo(BigInteger.ZERO) > 0)@b@ displaySize = String.valueOf(size.divide(ONE_TB_BI)) + " TB";@b@ else if (size.divide(ONE_GB_BI).compareTo(BigInteger.ZERO) > 0)@b@ displaySize = String.valueOf(size.divide(ONE_GB_BI)) + " GB";@b@ else if (size.divide(ONE_MB_BI).compareTo(BigInteger.ZERO) > 0)@b@ displaySize = String.valueOf(size.divide(ONE_MB_BI)) + " MB";@b@ else if (size.divide(ONE_KB_BI).compareTo(BigInteger.ZERO) > 0)@b@ displaySize = String.valueOf(size.divide(ONE_KB_BI)) + " KB";@b@ else@b@ displaySize = String.valueOf(size) + " bytes";@b@@b@ return displaySize;@b@ }@b@@b@ public static String byteCountToDisplaySize(long size)@b@ {@b@ return byteCountToDisplaySize(BigInteger.valueOf(size));@b@ }@b@@b@ public static void touch(File file)@b@ throws IOException@b@ {@b@ if (!(file.exists())) {@b@ OutputStream out = openOutputStream(file);@b@ IOUtils.closeQuietly(out);@b@ }@b@ boolean success = file.setLastModified(System.currentTimeMillis());@b@ if (!(success))@b@ throw new IOException("Unable to set the last modification time for " + file);@b@ }@b@@b@ public static File[] convertFileCollectionToFileArray(Collection files)@b@ {@b@ return ((File[])files.toArray(new File[files.size()]));@b@ }@b@@b@ private static void innerListFiles(Collection files, File directory, IOFileFilter filter, boolean includeSubDirectories)@b@ {@b@ File[] arr$;@b@ int i$;@b@ File[] found = directory.listFiles(filter);@b@@b@ if (found != null) {@b@ arr$ = found; int len$ = arr$.length; for (i$ = 0; i$ listFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter)@b@ {@b@ validateListFilesParameters(directory, fileFilter);@b@@b@ IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter);@b@ IOFileFilter effDirFilter = setUpEffectiveDirFilter(dirFilter);@b@@b@ Collection files = new LinkedList();@b@ innerListFiles(files, directory, FileFilterUtils.or(new IOFileFilter[] { effFileFilter, effDirFilter }), false);@b@@b@ return files;@b@ }@b@@b@ private static void validateListFilesParameters(File directory, IOFileFilter fileFilter)@b@ {@b@ if (!(directory.isDirectory()))@b@ throw new IllegalArgumentException("Parameter 'directory' is not a directory");@b@@b@ if (fileFilter == null)@b@ throw new NullPointerException("Parameter 'fileFilter' is null");@b@ }@b@@b@ private static IOFileFilter setUpEffectiveFileFilter(IOFileFilter fileFilter)@b@ {@b@ return FileFilterUtils.and(new IOFileFilter[] { fileFilter, FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE) });@b@ }@b@@b@ private static IOFileFilter setUpEffectiveDirFilter(IOFileFilter dirFilter)@b@ {@b@ return ((dirFilter == null) ? FalseFileFilter.INSTANCE : FileFilterUtils.and(new IOFileFilter[] { dirFilter, DirectoryFileFilter.INSTANCE }));@b@ }@b@@b@ public static Collection listFilesAndDirs(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter)@b@ {@b@ validateListFilesParameters(directory, fileFilter);@b@@b@ IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter);@b@ IOFileFilter effDirFilter = setUpEffectiveDirFilter(dirFilter);@b@@b@ Collection files = new LinkedList();@b@ if (directory.isDirectory())@b@ files.add(directory);@b@@b@ innerListFiles(files, directory, FileFilterUtils.or(new IOFileFilter[] { effFileFilter, effDirFilter }), true);@b@@b@ return files;@b@ }@b@@b@ public static Iterator iterateFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter)@b@ {@b@ return listFiles(directory, fileFilter, dirFilter).iterator();@b@ }@b@@b@ public static Iterator iterateFilesAndDirs(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter)@b@ {@b@ return listFilesAndDirs(directory, fileFilter, dirFilter).iterator();@b@ }@b@@b@ private static String[] toSuffixes(String[] extensions)@b@ {@b@ String[] suffixes = new String[extensions.length];@b@ for (int i = 0; i listFiles(File directory, String[] extensions, boolean recursive)@b@ {@b@ IOFileFilter filter;@b@ if (extensions == null) {@b@ filter = TrueFileFilter.INSTANCE;@b@ } else {@b@ String[] suffixes = toSuffixes(extensions);@b@ filter = new SuffixFileFilter(suffixes);@b@ }@b@ return listFiles(directory, filter, (recursive) ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE);@b@ }@b@@b@ public static Iterator iterateFiles(File directory, String[] extensions, boolean recursive)@b@ {@b@ return listFiles(directory, extensions, recursive).iterator();@b@ }@b@@b@ public static boolean contentEquals(File file1, File file2)@b@ throws IOException@b@ {@b@ boolean file1Exists = file1.exists();@b@ if (file1Exists != file2.exists()) {@b@ return false;@b@ }@b@@b@ if (!(file1Exists))@b@ {@b@ return true;@b@ }@b@@b@ if ((file1.isDirectory()) || (file2.isDirectory()))@b@ {@b@ throw new IOException("Can't compare directories, only files");@b@ }@b@@b@ if (file1.length() != file2.length())@b@ {@b@ return false;@b@ }@b@@b@ if (file1.getCanonicalFile().equals(file2.getCanonicalFile()))@b@ {@b@ return true;@b@ }@b@@b@ InputStream input1 = null;@b@ InputStream input2 = null;@b@ try {@b@ input1 = new FileInputStream(file1);@b@ input2 = new FileInputStream(file2);@b@ boolean bool1 = IOUtils.contentEquals(input1, input2);@b@@b@ return bool1;@b@ }@b@ finally@b@ {@b@ IOUtils.closeQuietly(input1);@b@ IOUtils.closeQuietly(input2);@b@ }@b@ }@b@@b@ public static boolean contentEqualsIgnoreEOL(File file1, File file2, String charsetName)@b@ throws IOException@b@ {@b@ boolean file1Exists = file1.exists();@b@ if (file1Exists != file2.exists()) {@b@ return false;@b@ }@b@@b@ if (!(file1Exists))@b@ {@b@ return true;@b@ }@b@@b@ if ((file1.isDirectory()) || (file2.isDirectory()))@b@ {@b@ throw new IOException("Can't compare directories, only files");@b@ }@b@@b@ if (file1.getCanonicalFile().equals(file2.getCanonicalFile()))@b@ {@b@ return true;@b@ }@b@@b@ Reader input1 = null;@b@ Reader input2 = null;@b@ try {@b@ if (charsetName == null) {@b@ input1 = new InputStreamReader(new FileInputStream(file1));@b@ input2 = new InputStreamReader(new FileInputStream(file2));@b@ } else {@b@ input1 = new InputStreamReader(new FileInputStream(file1), charsetName);@b@ input2 = new InputStreamReader(new FileInputStream(file2), charsetName);@b@ }@b@ boolean bool1 = IOUtils.contentEqualsIgnoreEOL(input1, input2);@b@@b@ return bool1;@b@ }@b@ finally@b@ {@b@ IOUtils.closeQuietly(input1);@b@ IOUtils.closeQuietly(input2);@b@ }@b@ }@b@@b@ public static File toFile(URL url)@b@ {@b@ if ((url == null) || (!("file".equalsIgnoreCase(url.getProtocol()))))@b@ return null;@b@@b@ String filename = url.getFile().replace('/', File.separatorChar);@b@ filename = decodeUrl(filename);@b@ return new File(filename); } @b@ // ERROR //@b@ static String decodeUrl(String url) { // Byte code:@b@ @b@ public static File[] toFiles(URL[] urls) { if ((urls == null) || (urls.length == 0))@b@ return EMPTY_FILE_ARRAY;@b@@b@ File[] files = new File[urls.length];@b@ for (int i = 0; i 31457280L) ? 31457280L : size - pos;@b@ pos += output.transferFrom(input, pos, count);@b@ }@b@ } finally {@b@ IOUtils.closeQuietly(output);@b@ IOUtils.closeQuietly(fos);@b@ IOUtils.closeQuietly(input);@b@ IOUtils.closeQuietly(fis);@b@ }@b@@b@ if (srcFile.length() != destFile.length()) {@b@ throw new IOException("Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'");@b@ }@b@@b@ if (preserveFileDate)@b@ destFile.setLastModified(srcFile.lastModified());@b@ }@b@@b@ public static void copyDirectoryToDirectory(File srcDir, File destDir)@b@ throws IOException@b@ {@b@ if (srcDir == null)@b@ throw new NullPointerException("Source must not be null");@b@@b@ if ((srcDir.exists()) && (!(srcDir.isDirectory())))@b@ throw new IllegalArgumentException("Source '" + destDir + "' is not a directory");@b@@b@ if (destDir == null)@b@ throw new NullPointerException("Destination must not be null");@b@@b@ if ((destDir.exists()) && (!(destDir.isDirectory())))@b@ throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory");@b@@b@ copyDirectory(srcDir, new File(destDir, srcDir.getName()), true);@b@ }@b@@b@ public static void copyDirectory(File srcDir, File destDir)@b@ throws IOException@b@ {@b@ copyDirectory(srcDir, destDir, true);@b@ }@b@@b@ public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate)@b@ throws IOException@b@ {@b@ copyDirectory(srcDir, destDir, null, preserveFileDate);@b@ }@b@@b@ public static void copyDirectory(File srcDir, File destDir, FileFilter filter)@b@ throws IOException@b@ {@b@ copyDirectory(srcDir, destDir, filter, true);@b@ }@b@@b@ public static void copyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate)@b@ throws IOException@b@ {@b@ File[] arr$;@b@ int i$;@b@ if (srcDir == null)@b@ throw new NullPointerException("Source must not be null");@b@@b@ if (destDir == null)@b@ throw new NullPointerException("Destination must not be null");@b@@b@ if (!(srcDir.exists()))@b@ throw new FileNotFoundException("Source '" + srcDir + "' does not exist");@b@@b@ if (!(srcDir.isDirectory()))@b@ throw new IOException("Source '" + srcDir + "' exists but is not a directory");@b@@b@ if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) {@b@ throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same");@b@ }@b@@b@ List exclusionList = null;@b@ if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {@b@ File[] srcFiles = (filter == null) ? srcDir.listFiles() : srcDir.listFiles(filter);@b@ if ((srcFiles != null) && (srcFiles.length > 0)) {@b@ exclusionList = new ArrayList(srcFiles.length);@b@ arr$ = srcFiles; int len$ = arr$.length; for (i$ = 0; i$ exclusionList)@b@ throws IOException@b@ {@b@ File[] srcFiles = (filter == null) ? srcDir.listFiles() : srcDir.listFiles(filter);@b@ if (srcFiles == null)@b@ throw new IOException("Failed to list contents of " + srcDir);@b@@b@ if (destDir.exists()) {@b@ if (destDir.isDirectory()) break label142;@b@ throw new IOException("Destination '" + destDir + "' exists but is not a directory");@b@ }@b@@b@ if ((!(destDir.mkdirs())) && (!(destDir.isDirectory()))) {@b@ throw new IOException("Destination '" + destDir + "' directory cannot be created");@b@ }@b@@b@ if (!(destDir.canWrite()))@b@ label142: throw new IOException("Destination '" + destDir + "' cannot be written to");@b@@b@ File[] arr$ = srcFiles; int len$ = arr$.length; for (int i$ = 0; i$ = 10) {@b@ tick = 0;@b@ if (timeout++ > seconds)@b@ return false;@b@ }@b@ try@b@ {@b@ Thread.sleep(100L);@b@ } catch (InterruptedException ignore) {@b@ }@b@ catch (Exception ex) {@b@ break label51:@b@ }@b@ }@b@ label51: return true;@b@ }@b@@b@ public static String readFileToString(File file, Charset encoding)@b@ throws IOException@b@ {@b@ InputStream in = null;@b@ try {@b@ in = openInputStream(file);@b@ String str = IOUtils.toString(in, Charsets.toCharset(encoding));@b@@b@ return str; } finally { IOUtils.closeQuietly(in);@b@ }@b@ }@b@@b@ public static String readFileToString(File file, String encoding)@b@ throws IOException@b@ {@b@ return readFileToString(file, Charsets.toCharset(encoding));@b@ }@b@@b@ public static String readFileToString(File file)@b@ throws IOException@b@ {@b@ return readFileToString(file, Charset.defaultCharset());@b@ }@b@@b@ public static byte[] readFileToByteArray(File file)@b@ throws IOException@b@ {@b@ InputStream in = null;@b@ try {@b@ in = openInputStream(file);@b@ byte[] arrayOfByte = IOUtils.toByteArray(in, file.length());@b@@b@ return arrayOfByte; } finally { IOUtils.closeQuietly(in);@b@ }@b@ }@b@@b@ public static List readLines(File file, Charset encoding)@b@ throws IOException@b@ {@b@ InputStream in = null;@b@ try {@b@ in = openInputStream(file);@b@ List localList = IOUtils.readLines(in, Charsets.toCharset(encoding));@b@@b@ return localList; } finally { IOUtils.closeQuietly(in);@b@ }@b@ }@b@@b@ public static List readLines(File file, String encoding)@b@ throws IOException@b@ {@b@ return readLines(file, Charsets.toCharset(encoding));@b@ }@b@@b@ public static List readLines(File file)@b@ throws IOException@b@ {@b@ return readLines(file, Charset.defaultCharset());@b@ }@b@@b@ public static LineIterator lineIterator(File file, String encoding)@b@ throws IOException@b@ {@b@ InputStream in = null;@b@ try {@b@ in = openInputStream(file);@b@ return IOUtils.lineIterator(in, encoding);@b@ } catch (IOException ex) {@b@ IOUtils.closeQuietly(in);@b@ throw ex;@b@ } catch (RuntimeException ex) {@b@ IOUtils.closeQuietly(in);@b@ throw ex;@b@ }@b@ }@b@@b@ public static LineIterator lineIterator(File file)@b@ throws IOException@b@ {@b@ return lineIterator(file, null);@b@ }@b@@b@ public static void writeStringToFile(File file, String data, Charset encoding)@b@ throws IOException@b@ {@b@ writeStringToFile(file, data, encoding, false);@b@ }@b@@b@ public static void writeStringToFile(File file, String data, String encoding)@b@ throws IOException@b@ {@b@ writeStringToFile(file, data, encoding, false);@b@ }@b@@b@ public static void writeStringToFile(File file, String data, Charset encoding, boolean append)@b@ throws IOException@b@ {@b@ OutputStream out = null;@b@ try {@b@ out = openOutputStream(file, append);@b@ IOUtils.write(data, out, encoding);@b@ out.close();@b@ } finally {@b@ IOUtils.closeQuietly(out);@b@ }@b@ }@b@@b@ public static void writeStringToFile(File file, String data, String encoding, boolean append)@b@ throws IOException@b@ {@b@ writeStringToFile(file, data, Charsets.toCharset(encoding), append);@b@ }@b@@b@ public static void writeStringToFile(File file, String data)@b@ throws IOException@b@ {@b@ writeStringToFile(file, data, Charset.defaultCharset(), false);@b@ }@b@@b@ public static void writeStringToFile(File file, String data, boolean append)@b@ throws IOException@b@ {@b@ writeStringToFile(file, data, Charset.defaultCharset(), append);@b@ }@b@@b@ public static void write(File file, CharSequence data)@b@ throws IOException@b@ {@b@ write(file, data, Charset.defaultCharset(), false);@b@ }@b@@b@ public static void write(File file, CharSequence data, boolean append)@b@ throws IOException@b@ {@b@ write(file, data, Charset.defaultCharset(), append);@b@ }@b@@b@ public static void write(File file, CharSequence data, Charset encoding)@b@ throws IOException@b@ {@b@ write(file, data, encoding, false);@b@ }@b@@b@ public static void write(File file, CharSequence data, String encoding)@b@ throws IOException@b@ {@b@ write(file, data, encoding, false);@b@ }@b@@b@ public static void write(File file, CharSequence data, Charset encoding, boolean append)@b@ throws IOException@b@ {@b@ String str = (data == null) ? null : data.toString();@b@ writeStringToFile(file, str, encoding, append);@b@ }@b@@b@ public static void write(File file, CharSequence data, String encoding, boolean append)@b@ throws IOException@b@ {@b@ write(file, data, Charsets.toCharset(encoding), append);@b@ }@b@@b@ public static void writeByteArrayToFile(File file, byte[] data)@b@ throws IOException@b@ {@b@ writeByteArrayToFile(file, data, false);@b@ }@b@@b@ public static void writeByteArrayToFile(File file, byte[] data, boolean append)@b@ throws IOException@b@ {@b@ OutputStream out = null;@b@ try {@b@ out = openOutputStream(file, append);@b@ out.write(data);@b@ out.close();@b@ } finally {@b@ IOUtils.closeQuietly(out);@b@ }@b@ }@b@@b@ public static void writeLines(File file, String encoding, Collection> lines)@b@ throws IOException@b@ {@b@ writeLines(file, encoding, lines, null, false);@b@ }@b@@b@ public static void writeLines(File file, String encoding, Collection> lines, boolean append)@b@ throws IOException@b@ {@b@ writeLines(file, encoding, lines, null, append);@b@ }@b@@b@ public static void writeLines(File file, Collection> lines)@b@ throws IOException@b@ {@b@ writeLines(file, null, lines, null, false);@b@ }@b@@b@ public static void writeLines(File file, Collection> lines, boolean append)@b@ throws IOException@b@ {@b@ writeLines(file, null, lines, null, append);@b@ }@b@@b@ public static void writeLines(File file, String encoding, Collection> lines, String lineEnding)@b@ throws IOException@b@ {@b@ writeLines(file, encoding, lines, lineEnding, false);@b@ }@b@@b@ public static void writeLines(File file, String encoding, Collection> lines, String lineEnding, boolean append)@b@ throws IOException@b@ {@b@ FileOutputStream out = null;@b@ try {@b@ out = openOutputStream(file, append);@b@ BufferedOutputStream buffer = new BufferedOutputStream(out);@b@ IOUtils.writeLines(lines, lineEnding, buffer, encoding);@b@ buffer.flush();@b@ out.close();@b@ } finally {@b@ IOUtils.closeQuietly(out);@b@ }@b@ }@b@@b@ public static void writeLines(File file, Collection> lines, String lineEnding)@b@ throws IOException@b@ {@b@ writeLines(file, null, lines, lineEnding, false);@b@ }@b@@b@ public static void writeLines(File file, Collection> lines, String lineEnding, boolean append)@b@ throws IOException@b@ {@b@ writeLines(file, null, lines, lineEnding, append);@b@ }@b@@b@ public static void forceDelete(File file)@b@ throws IOException@b@ {@b@ if (file.isDirectory()) {@b@ deleteDirectory(file);@b@ } else {@b@ boolean filePresent = file.exists();@b@ if (!(file.delete())) {@b@ if (!(filePresent))@b@ throw new FileNotFoundException("File does not exist: " + file);@b@@b@ String message = "Unable to delete file: " + file;@b@@b@ throw new IOException(message);@b@ }@b@ }@b@ }@b@@b@ public static void forceDeleteOnExit(File file)@b@ throws IOException@b@ {@b@ if (file.isDirectory())@b@ deleteDirectoryOnExit(file);@b@ else@b@ file.deleteOnExit();@b@ }@b@@b@ private static void deleteDirectoryOnExit(File directory)@b@ throws IOException@b@ {@b@ if (!(directory.exists())) {@b@ return;@b@ }@b@@b@ directory.deleteOnExit();@b@ if (!(isSymlink(directory)))@b@ cleanDirectoryOnExit(directory);@b@ }@b@@b@ private static void cleanDirectoryOnExit(File directory)@b@ throws IOException@b@ {@b@ String message;@b@ if (!(directory.exists())) {@b@ message = directory + " does not exist";@b@ throw new IllegalArgumentException(message);@b@ }@b@@b@ if (!(directory.isDirectory())) {@b@ message = directory + " is not a directory";@b@ throw new IllegalArgumentException(message);@b@ }@b@@b@ File[] files = directory.listFiles();@b@ if (files == null) {@b@ throw new IOException("Failed to list contents of " + directory);@b@ }@b@@b@ IOException exception = null;@b@ File[] arr$ = files; int len$ = arr$.length; for (int i$ = 0; i$ timeMillis);@b@ }@b@@b@ public static boolean isFileOlder(File file, File reference)@b@ {@b@ if (reference == null)@b@ throw new IllegalArgumentException("No specified reference file");@b@@b@ if (!(reference.exists())) {@b@ throw new IllegalArgumentException("The reference file '" + reference + "' doesn't exist");@b@ }@b@@b@ return isFileOlder(file, reference.lastModified());@b@ }@b@@b@ public static boolean isFileOlder(File file, Date date)@b@ {@b@ if (date == null)@b@ throw new IllegalArgumentException("No specified date");@b@@b@ return isFileOlder(file, date.getTime());@b@ }@b@@b@ public static boolean isFileOlder(File file, long timeMillis)@b@ {@b@ if (file == null)@b@ throw new IllegalArgumentException("No specified file");@b@@b@ if (!(file.exists()))@b@ return false;@b@@b@ return (file.lastModified()