|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sourceforge.java.util.io.FileUtils
Contains File related utility methods.
| Nested Class Summary | |
static class |
FileUtils.FileComparator
Abstract base Comparator for file attributes.
|
private static class |
FileUtils.FileDateComparator
Comparator to compare File objects based on
their file modification date attributes.
|
private static class |
FileUtils.FileNameComparator
Comparator to compare File objects based on
their file name attributes.
|
private static class |
FileUtils.FileSizeComparator
Comparator to compare File objects by their
size attribute.
|
| Field Summary | |
static FileUtils.FileDateComparator |
FILE_DATE_COMPARATOR
The default Comparator to compare File
objects based on their file modification date attributes.
|
static FileUtils.FileNameComparator |
FILE_NAME_COMPARATOR
The default Comparator to compare File
objects based on their file name attributes.
|
static String |
FILE_SEPARATOR
The default operating system file separator char |
static FileUtils.FileSizeComparator |
FILE_SIZE_COMPARATOR
The default Comparator to compare File
objects based on their file size attributes.
|
private static int |
KILOBYTE
The number of bytes of a kilobyte |
| Constructor Summary | |
FileUtils()
|
|
| Method Summary | |
static String |
addFileExtension(String fileName,
String extension)
Adds the specified file extension to the specified
fileName in case no extension has been set.
|
static boolean |
containsFile(File directory,
File f,
boolean recursive)
Returns true if the specified directory
contains the specified File.
|
static void |
copyFile(File sourceFile,
File targetFile)
Copies the File denoted by sourcFile to the
specified targetFile.
|
static void |
deleteRecursive(File file)
Deletes the specified directory recursively. |
static String |
getFileExtension(File f)
Gets the extension of the specified File.
|
static String |
getFileExtension(String filename)
Gets the extension of the File denoted by the
specified filename.
|
static double |
getSize(File file)
Gets the size of the specified File. |
static double |
getSize(String filename)
Gets the size of the File spedified by the given
filename. |
static boolean |
isReadable(File f)
Tests if the File denoted by f is readable,
i.e. read access is guaranteed.
|
static boolean |
isWriteable(File f)
Tests if the File denoted by f is writeable,
i.e. write access is guaranteed.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String FILE_SEPARATOR
The default operating system file separator char
public static final FileUtils.FileNameComparator FILE_NAME_COMPARATOR
The default Comparator to compare File
objects based on their file name attributes.
public static final FileUtils.FileSizeComparator FILE_SIZE_COMPARATOR
The default Comparator to compare File
objects based on their file size attributes.
public static final FileUtils.FileDateComparator FILE_DATE_COMPARATOR
The default Comparator to compare File
objects based on their file modification date attributes.
private static final int KILOBYTE
The number of bytes of a kilobyte
| Constructor Detail |
public FileUtils()
| Method Detail |
public static String addFileExtension(String fileName,
String extension)
Adds the specified file extension to the specified
fileName in case no extension has been set.
fileName - the file name to add the specified file
extension toextension - the extension to add (without the . character, e.g. xml)
fileNamepublic static String getFileExtension(File f)
Gets the extension of the specified File.
f - the File to get the extension for
File or an empty
String if the File has no extensionpublic static String getFileExtension(String filename)
Gets the extension of the File denoted by the
specified filename.
filename - the name of the File to get the extension
for
File denoted by the specified
filename or an empty String if no extension
set in the specified filenamepublic static void deleteRecursive(File file)
Deletes the specified directory recursively. If the specified
File is not a directory it is deleted directly.
file - the directory or file to deletepublic static double getSize(String filename)
Gets the size of the File spedified by the given
filename. If filename denotes a directory the
size is determined for the directory itself and recursively for all of
its sub directories.
filename - the name of the File to get the size for
public static double getSize(File file)
Gets the size of the specified File. If file
denotes a directory the size is determined for the directory itself and
recursively for all of its sub directories.
file - the File to get the size for
public static boolean containsFile(File directory,
File f,
boolean recursive)
Returns true if the specified directory
contains the specified File.
directory - the directory to search inf - the File to searchrecursive - true to search recursive;
false to search non recursive
true if the specified directory
contains the specified File; false otherwise
public static void copyFile(File sourceFile,
File targetFile)
throws FileNotFoundException,
IOException
Copies the File denoted by sourcFile to the
specified targetFile.
sourceFile - the source of the copy operationtargetFile - the traget of the copy operation
FileNotFoundException - if either the sourcFile or
the targetFile doesn't exist
IOException - if the copy operation failed due to an io errorpublic static boolean isReadable(File f)
Tests if the File denoted by f is readable,
i.e. read access is guaranteed.
f - the File to test
true if the specified File is
readable; false otherwisepublic static boolean isWriteable(File f)
Tests if the File denoted by f is writeable,
i.e. write access is guaranteed.
f - the File to test
true if the specified File is
writeable; false otherwise
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||