|
|||||||||
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 java.lang.String |
DefaultBackupFileSuffix
|
static int |
DefaultMaxBackupNumber
|
Method Summary | |
---|---|
static void |
createDirsForFile(java.io.File file)
Create directories for file if they do not exist. |
static void |
delete(java.io.File toDelete)
Deletes the file identified by toDelete . |
static void |
deleteAndRename(java.io.File toDelete,
java.io.File toRename)
Convenience method that deletes toDelete and renames
toRename to toDelete . |
static boolean |
deleteFile(java.io.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(java.io.File dir,
java.io.FilenameFilter filter)
Deletes the files in a specific directory that satisfy the filter. |
static void |
deleteSubdirectoryIfEmpty(java.io.FileFilter purgeTempFileFilter,
java.io.File dir,
boolean removeSelf)
|
static java.io.File |
directory(java.io.File dir)
Returns the File for a directory. |
static java.io.File |
directory(java.io.File base,
java.lang.String dir)
Returns the File for a named directory. |
static java.io.File |
directory(java.lang.String dir)
Returns the File for a named directory. |
static java.io.File |
directory(java.lang.String base,
java.lang.String dir)
Returns the File for a named directory. |
static java.io.File |
fixFileSeparators(java.io.File file)
Fix up file separators for platform independence. |
static java.lang.String |
fixFileSeparators(java.lang.String filename)
Fix up filename separators for platform independence. |
static java.io.File |
getCanonicalFile(java.io.File file)
Convert a file to canonical form. |
static java.util.List |
getSharedTempDirSnapshot()
Get a snapshot of the contents of shared temp dir. |
static boolean |
isAbsolutePath(java.lang.String path)
Determines if the path specified by a given String is an absolute path or not. |
static java.io.File[] |
ListFiles(java.io.File dir,
java.io.FilenameFilter filter)
Lists the files in a specific directory that satisfy the filter. |
static java.lang.String |
makeFileName(java.lang.String prefix,
java.lang.String filename)
Makes a 'standard' helper file name. |
static java.io.File |
mostRecentModifiedFile(java.io.File dir,
java.io.FilenameFilter filter)
Returns the most recently modified file in a specific directory that satisfies the filter. |
static java.lang.String |
parseFileExtension(java.lang.String filename)
Returns the extension of the given filename. |
static java.lang.String |
parseFileName(java.lang.String path)
Returns the filename or last name in the path. |
static int |
purgeDir(java.io.File dir,
java.io.FileFilter filter)
Recursively remove all files from the specified directory. |
static int |
purgeDir(java.io.File dir,
java.io.FileFilter filter,
int minimumAgeInHours)
|
static void |
purgeLocalTempDir()
Recursively remove all files from the local temp directory. |
static void |
purgeLocalTempDir(java.io.FileFilter filter,
int minimumDirAge)
Recursively remove all files from the local temp directory. |
static void |
purgeSharedTempDir()
Recursively remove all files from the shared temp directory. |
static void |
purgeSharedTempDir(java.io.FileFilter filter)
Recursively remove all files from the shared temp directory. |
static void |
purgeSharedTempDir(java.io.FileFilter filter,
int minimumDirAge)
Recursively remove all files from the shared temp directory. |
static void |
purgeSharedTempDirSnapshot(java.util.List sharedTempDirSnapshot,
long baseTime)
Purge the temp shared dir by only removing the files specified in the snapshot input parameter. |
static void |
rename(java.io.File fromFile,
java.io.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 java.lang.String DefaultBackupFileSuffix
public static final int DefaultMaxBackupNumber
Method Detail |
---|
public static java.io.File fixFileSeparators(java.io.File file)
file
- a file potentially with non platform
specific file separator characters ("/" or "\")
public static java.lang.String fixFileSeparators(java.lang.String filename)
filename
- a filename potentially with non platform
specific file separator characters ("/" or "\")
public static java.io.File directory(java.io.File base, java.lang.String dir) throws java.io.IOException
base
- the parent directory of dirdir
- the name of the directory to find or create
java.io.IOException
- if there was an error finding or
creating the directorypublic static java.io.File directory(java.lang.String base, java.lang.String dir) throws java.io.IOException
base
- the parent directory of dirdir
- the name of the directory to find or create
java.io.IOException
- if there was an error finding or
creating the directorypublic static java.io.File directory(java.lang.String dir) throws java.io.IOException
dir
- the name of the directory to find or create
java.io.IOException
- if there was an error finding or
creating the directorypublic static java.io.File directory(java.io.File dir) throws java.io.IOException
dir
- the directory to find or create
java.io.IOException
- if there was an error finding or
creating the directorypublic static java.io.File getCanonicalFile(java.io.File file)
file
- the file to convert to canonical form
public static void createDirsForFile(java.io.File file) throws java.io.IOException
file
- the file containing possibly non-existent directories
java.io.IOException
- if there was an error finding or creating the directorypublic static boolean deleteFile(java.io.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
otherwisepublic static void delete(java.io.File toDelete) throws FileUtil.FileDeletionException
toDelete
.
FileUtil.FileDeletionException
- if toDelete
cannot be deletedpublic static void rename(java.io.File fromFile, java.io.File toFile) throws FileUtil.FileRenameException
fromFile
to toFile
.
FileUtil.FileRenameException
- if fromFile
cannot be
renamed to toFilepublic static void deleteAndRename(java.io.File toDelete, java.io.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(java.lang.String path)
path
- the input String.
public static void purgeLocalTempDir()
java.lang.SecurityException
- if some files don't have read access.public static void purgeLocalTempDir(java.io.FileFilter filter, int minimumDirAge)
filter
- the selection filter for the directory and its subdirectories;
May be null to indicate that all files are to be deleted.
java.lang.SecurityException
- if some files don't have read access.public static void purgeSharedTempDir()
java.lang.SecurityException
- if some files don't have read access.public static void purgeSharedTempDir(java.io.FileFilter filter)
filter
- the selection filter for the directory and its subdirectories;
May be null to indicate that all files are to be deleted.
java.lang.SecurityException
- if some files don't have read access.public static void purgeSharedTempDir(java.io.FileFilter filter, int minimumDirAge)
filter
- the selection filter for the directory and its subdirectories;
May be null to indicate that all files are to be deleted.
java.lang.SecurityException
- if some files don't have read access.public static java.util.List getSharedTempDirSnapshot()
public static void purgeSharedTempDirSnapshot(java.util.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(java.io.File dir, java.io.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.
java.lang.SecurityException
- if some files don't have read access.public static int purgeDir(java.io.File dir, java.io.FileFilter filter, int minimumAgeInHours)
public static void deleteSubdirectoryIfEmpty(java.io.FileFilter purgeTempFileFilter, java.io.File dir, boolean removeSelf)
public static java.io.File[] ListFiles(java.io.File dir, java.io.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(java.io.File dir, java.io.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 deletedpublic static java.io.File mostRecentModifiedFile(java.io.File dir, java.io.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
public static java.lang.String makeFileName(java.lang.String prefix, java.lang.String filename)
prefix
- filename
-
public static java.lang.String parseFileName(java.lang.String path)
path
-
public static java.lang.String parseFileExtension(java.lang.String filename)
filename
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |