|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.archive.util.FileUtils
public class FileUtils
Utility methods for manipulating files and directories.
Field Summary | |
---|---|
(package private) static java.util.LinkedList<java.io.File> |
pendingDeletes
|
static java.io.File |
TMPDIR
|
Method Summary | |
---|---|
static boolean |
copyFile(java.io.File src,
java.io.File dest)
Copy the src file to the destination. |
static boolean |
copyFile(java.io.File src,
java.io.File dest,
boolean overwrite)
Copy the src file to the destination. |
static boolean |
copyFile(java.io.File src,
java.io.File dest,
long extent)
Copy up to extent bytes of the source file to the destination |
static boolean |
copyFile(java.io.File src,
java.io.File dest,
long extent,
boolean overwrite)
Copy up to extent bytes of the source file to the destination |
static void |
copyFiles(java.io.File src,
java.io.File dest)
Recursively copy all files from one directory to another. |
static void |
copyFiles(java.io.File src,
java.io.FilenameFilter filter,
java.io.File dest,
boolean inSortedOrder,
boolean overwrite)
Recursively copy all files from one directory to another. |
static void |
copyFiles(java.io.File src,
java.io.FilenameFilter filter,
java.io.File dest,
boolean inSortedOrder,
boolean overwrite,
java.util.List<java.io.IOException> exceptions)
Recursively copy all files from one directory to another. |
static int |
copyFiles(java.io.File srcDir,
java.util.Set srcFile,
java.io.File dest)
|
static boolean |
deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir. |
static void |
deleteSoonerOrLater(java.io.File fileToDelete)
Delete the file now -- but in the event of failure, keep trying in the future. |
static java.io.File[] |
getFilesWithPrefix(java.io.File dir,
java.lang.String prefix)
Get a list of all files in directory that have passed prefix. |
static java.io.FileFilter |
getRegexpFileFilter(java.lang.String regexp)
Get a @link java.io.FileFilter that filters files based on a regular expression. |
static java.lang.String[] |
getSortedDirContent(java.io.File src,
java.io.FilenameFilter filter)
|
static java.io.File |
isReadable(java.io.File f)
Test file exists and is readable. |
static boolean |
isReadableWithExtensionAndMagic(java.io.File f,
java.lang.String uncompressedExtension,
java.lang.String magic)
|
static java.io.File |
maybeRelative(java.io.File context,
java.lang.String path)
Turn path into a File, relative to context (which may be ignored if path is absolute). |
static java.lang.String |
readFileAsString(java.io.File file)
Utility method to read an entire file as a String. |
static void |
syncDirectories(java.io.File src,
java.io.FilenameFilter filter,
java.io.File tgt)
Use for case where files are being added to src. |
protected static void |
workaroundCopyFile(java.io.File src,
java.io.File dest)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.io.File TMPDIR
static java.util.LinkedList<java.io.File> pendingDeletes
Method Detail |
---|
public static int copyFiles(java.io.File srcDir, java.util.Set srcFile, java.io.File dest) throws java.io.IOException
java.io.IOException
public static void copyFiles(java.io.File src, java.io.File dest) throws java.io.IOException
src
- file or directory to copy from.dest
- file or directory to copy to.
java.io.IOException
public static java.lang.String[] getSortedDirContent(java.io.File src, java.io.FilenameFilter filter)
src
- Directory of files to fetch.filter
- Filter to apply to filenames.
public static void copyFiles(java.io.File src, java.io.FilenameFilter filter, java.io.File dest, boolean inSortedOrder, boolean overwrite) throws java.io.IOException
src
- File or directory to copy from.filter
- Filename filter to apply to src. May be null if no
filtering wanted.dest
- File or directory to copy to.inSortedOrder
- Copy in order of natural sort.overwrite
- If target file already exits, and this parameter is
true, overwrite target file (We do this by first deleting the target
file before we begin the copy).
java.io.IOException
public static void copyFiles(java.io.File src, java.io.FilenameFilter filter, java.io.File dest, boolean inSortedOrder, boolean overwrite, java.util.List<java.io.IOException> exceptions) throws java.io.IOException
src
- File or directory to copy from.filter
- Filename filter to apply to src. May be null if no
filtering wanted.dest
- File or directory to copy to.inSortedOrder
- Copy in order of natural sort.overwrite
- If target file already exits, and this parameter is
true, overwrite target file (We do this by first deleting the target
file before we begin the copy).exceptions
- if non-null, add any individual-file IOExceptions
to this List rather than throwing, and proceed with the deep copy
java.io.IOException
public static boolean copyFile(java.io.File src, java.io.File dest) throws java.io.FileNotFoundException, java.io.IOException
src
- dest
-
java.io.FileNotFoundException
java.io.IOException
public static boolean copyFile(java.io.File src, java.io.File dest, boolean overwrite) throws java.io.FileNotFoundException, java.io.IOException
src
- dest
- overwrite
- If target file already exits, and this parameter is
true, overwrite target file (We do this by first deleting the target
file before we begin the copy).
java.io.FileNotFoundException
java.io.IOException
public static boolean copyFile(java.io.File src, java.io.File dest, long extent) throws java.io.FileNotFoundException, java.io.IOException
src
- dest
- extent
- Maximum number of bytes to copy
java.io.FileNotFoundException
java.io.IOException
public static boolean copyFile(java.io.File src, java.io.File dest, long extent, boolean overwrite) throws java.io.FileNotFoundException, java.io.IOException
src
- dest
- extent
- Maximum number of bytes to copyoverwrite
- If target file already exits, and this parameter is
true, overwrite target file (We do this by first deleting the target
file before we begin the copy).
java.io.FileNotFoundException
java.io.IOException
protected static void workaroundCopyFile(java.io.File src, java.io.File dest) throws java.io.IOException
java.io.IOException
public static boolean deleteDir(java.io.File dir)
dir
-
public static java.lang.String readFileAsString(java.io.File file) throws java.io.IOException
file
-
java.io.IOException
public static java.io.File[] getFilesWithPrefix(java.io.File dir, java.lang.String prefix)
dir
- Dir to look in.prefix
- Basename of files to look for. Compare is case insensitive.
public static java.io.FileFilter getRegexpFileFilter(java.lang.String regexp)
regexp
- the regular expression the files must match.
public static void syncDirectories(java.io.File src, java.io.FilenameFilter filter, java.io.File tgt) throws java.io.IOException
src
- Source directory to copy from.tgt
- Target to copy to.filter
- Filter to apply to files to copy.
java.io.IOException
public static java.io.File isReadable(java.io.File f) throws java.io.IOException
f
- File to test.
java.io.IOException
- If file does not exist or is not unreadable.public static boolean isReadableWithExtensionAndMagic(java.io.File f, java.lang.String uncompressedExtension, java.lang.String magic) throws java.io.IOException
f
- File to test.
java.io.IOException
- If file does not exist or is not readable.public static java.io.File maybeRelative(java.io.File context, java.lang.String path)
context
- File context if path is relativepath
- String path to make into a File
public static void deleteSoonerOrLater(java.io.File fileToDelete)
fileToDelete
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |