|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectariba.util.core.FileUtil
public final class FileUtil
File Utilities. These are helper functions for dealing with files.
| Nested Class Summary | |
|---|---|
static class |
FileUtil.FileDeletionException
Represents the exceptional condition where we expected to be able to delete a file but were not actually able to do so. |
static class |
FileUtil.FileRenameException
Represents the exceptional condition where we expected to be able to rename a file but were not actually able to do so. |
| Field Summary | |
|---|---|
static String |
DefaultBackupFileSuffix
|
static int |
DefaultMaxBackupNumber
|
| Method Summary | |
|---|---|
static void |
createDirsForFile(File file)
Create directories for file if they do not exist. |
static void |
delete(File toDelete)
Deletes the file identified by toDelete. |
static void |
deleteAndRename(File toDelete,
File toRename)
Convenience method that deletes toDelete and renames
toRename to toDelete. |
static boolean |
deleteFile(File file)
Convenience method that will call delete() on
file and if that fails will call file.deleteOnExit()
scheduling the file for deletion upon normal server exit. |
static void |
DeleteFiles(File dir,
FilenameFilter filter)
Deletes the files in a specific directory that satisfy the filter. |
static File |
directory(File dir)
Returns the File for a directory. |
static File |
directory(File base,
String dir)
Returns the File for a named directory. |
static File |
directory(String dir)
Returns the File for a named directory. |
static File |
directory(String base,
String dir)
Returns the File for a named directory. |
static File |
fixFileSeparators(File file)
Fix up file separators for platform independence. |
static String |
fixFileSeparators(String filename)
Fix up filename separators for platform independence. |
static File |
getCanonicalFile(File file)
Convert a file to canonical form. |
static List |
getSharedTempDirSnapshot()
Get a snapshot of the contents of shared temp dir. |
static boolean |
isAbsolutePath(String path)
Determines if the path specified by a given String is an absolute path or not. |
static File[] |
ListFiles(File dir,
FilenameFilter filter)
Lists the files in a specific directory that satisfy the filter. |
static File |
mostRecentModifiedFile(File dir,
FilenameFilter filter)
Returns the most recently modified file in a specific directory that satisfies the filter. |
static int |
purgeDir(File dir,
FileFilter filter)
Recursively remove all files from the specified directory. |
static void |
purgeLocalTempDir()
Recursively remove all files from the local temp directory. |
static void |
purgeLocalTempDir(FileFilter filter)
Recursively remove all files from the local temp directory. |
static void |
purgeSharedTempDir()
Recursively remove all files from the shared temp directory. |
static void |
purgeSharedTempDir(FileFilter filter)
Recursively remove all files from the shared temp directory. |
static void |
purgeSharedTempDirSnapshot(List sharedTempDirSnapshot,
long baseTime)
Purge the temp shared dir by only removing the files specified in the snapshot input parameter. |
static void |
rename(File fromFile,
File toFile)
Renames fromFile to toFile. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DefaultBackupFileSuffix
public static final int DefaultMaxBackupNumber
| Method Detail |
|---|
public static File fixFileSeparators(File file)
file - a file potentially with non platform
specific file separator characters ("/" or "\")
public static String fixFileSeparators(String filename)
filename - a filename potentially with non platform
specific file separator characters ("/" or "\")
public static File directory(File base,
String dir)
throws IOException
base - the parent directory of dirdir - the name of the directory to find or create
IOException - if there was an error finding or
creating the directory
public static File directory(String base,
String dir)
throws IOException
base - the parent directory of dirdir - the name of the directory to find or create
IOException - if there was an error finding or
creating the directory
public static File directory(String dir)
throws IOException
dir - the name of the directory to find or create
IOException - if there was an error finding or
creating the directory
public static File directory(File dir)
throws IOException
dir - the directory to find or create
IOException - if there was an error finding or
creating the directorypublic static File getCanonicalFile(File file)
file - the file to convert to canonical form
public static void createDirsForFile(File file)
throws IOException
file - the file containing possibly non-existent directories
IOException - if there was an error finding or creating the directorypublic static boolean deleteFile(File file)
delete() on
file and if that fails will call file.deleteOnExit()
scheduling the file for deletion upon normal server exit.
file - the File to delete
true if file was immediately deleted and
false otherwise
public static void delete(File toDelete)
throws FileUtil.FileDeletionException
toDelete.
FileUtil.FileDeletionException - if toDelete cannot be deleted
public static void rename(File fromFile,
File toFile)
throws FileUtil.FileRenameException
fromFile to toFile.
FileUtil.FileRenameException - if fromFile cannot be
renamed to toFile
public static void deleteAndRename(File toDelete,
File toRename)
throws FileUtil.FileDeletionException,
FileUtil.FileRenameException
toDelete and renames
toRename to toDelete.
FileUtil.FileDeletionException - if toDelete cannot be deleted
FileUtil.FileRenameException - if toRename cannot be
renamed (assuming toDelete is deleted)public static boolean isAbsolutePath(String path)
path - the input String.
public static void purgeLocalTempDir()
SecurityException - if some files don't have read access.public static void purgeLocalTempDir(FileFilter filter)
filter - the selection filter for the directory and its subdirectories;
May be null to indicate that all files are to be deleted.
SecurityException - if some files don't have read access.public static void purgeSharedTempDir()
SecurityException - if some files don't have read access.public static void purgeSharedTempDir(FileFilter filter)
filter - the selection filter for the directory and its subdirectories;
May be null to indicate that all files are to be deleted.
SecurityException - if some files don't have read access.public static List getSharedTempDirSnapshot()
public static void purgeSharedTempDirSnapshot(List sharedTempDirSnapshot,
long baseTime)
sharedTempDirSnapshot - the list of the files inthe snapshot to be removed.
Note that the files can have relative or absolute paths. The directories
will not be removed.baseTime - a base time to be used for delteing the files. Files that are mmodified after
this base time will not be removed.
public static int purgeDir(File dir,
FileFilter filter)
dir - the root of the deletion processfilter - the selection filter for the directory and its subdirectories;
May be null to indicate that all files are to be deleted.
SecurityException - if some files don't have read access.
public static File[] ListFiles(File dir,
FilenameFilter filter)
dir - the directory containig the listing filesfilter - the selection filter for the files to be listed;
May be null, then all files in the dir will be listed
public static void DeleteFiles(File dir,
FilenameFilter filter)
dir - the directory containig the files to be deletedfilter - the selection filter for the files to be deleted;
May be null, then all files in the dir will be deleted
public static File mostRecentModifiedFile(File dir,
FilenameFilter filter)
dir - the directory containig the listing filesfilter - the selection filter for the files to be listed;
May be null, then all files in the dir will be considerd
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||