public class FileUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FileUtil.FileNameDateTimeComparator
Class to compare Files by their embedded DateTimes.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(File sourceFile,
File targetFile)
Copy the source file to the target file.
|
static boolean |
copy(File sourceFile,
File targetFile,
boolean overwrite)
Copy the source file to the target file while optionally permitting an
overwrite to occur in case the target file already exists.
|
static boolean |
equals(File file1,
File file2)
Tests whether the contents of two files equals each other by performing
a byte-by-byte comparison.
|
static File[] |
findFiles(File dir,
FileFilter filter)
Finds all files (non-recursively) in a directory based on the FileFilter.
|
static boolean |
isValidFileExtension(String extension)
Checks if the extension is valid.
|
static String |
parseFileExtension(String filename)
Parse the filename and return the file extension.
|
public static boolean equals(File file1, File file2) throws IOException
file1 - The file to comparefile2 - The other file to compareIOException - Thrown if there is an underlying IO error while
attempt to compare the bytes.public static boolean isValidFileExtension(String extension)
extension - The file extension to validatepublic static String parseFileExtension(String filename)
String - to process containing the filenamepublic static File[] findFiles(File dir, FileFilter filter) throws FileNotFoundException
FileNotFoundExceptionpublic static void copy(File sourceFile, File targetFile) throws FileAlreadyExistsException, IOException
sourceFile - The source file to copy fromtargetFile - The target file to copy toFileAlreadyExistsException - Thrown if the target file already
exists. This exception is a subclass of IOException, so catching
an IOException is enough if you don't care about this specific reason.IOException - Thrown if an error during the copypublic static boolean copy(File sourceFile, File targetFile, boolean overwrite) throws FileAlreadyExistsException, IOException
sourceFile - The source file to copy fromtargetFile - The target file to copy toFileAlreadyExistsException - Thrown if the target file already
exists and an overwrite is not permitted. This exception is a
subclass of IOException, so catching an IOException is enough if you
don't care about this specific reason.IOException - Thrown if an error during the copyCopyright © 2012-2015 Cloudhopper by Twitter. All Rights Reserved.