| java.lang.Object org.archive.util.FileUtils
FileUtils | public class FileUtils (Code) | | Utility methods for manipulating files and directories.
author: John Erik Halse |
Method Summary | |
public static boolean | copyFile(File src, File dest) Copy the src file to the destination. | public static boolean | copyFile(File src, File dest, boolean overwrite) Copy the src file to the destination.
Parameters: src - Parameters: dest - Parameters: overwrite - If target file already exits, and this parameter istrue, overwrite target file (We do this by first deleting the targetfile before we begin the copy). | public static boolean | copyFile(File src, File dest, long extent) | public static boolean | copyFile(File src, File dest, long extent, boolean overwrite) Copy up to extent bytes of the source file to the destination
Parameters: src - Parameters: dest - Parameters: extent - Maximum number of bytes to copy Parameters: overwrite - If target file already exits, and this parameter istrue, overwrite target file (We do this by first deleting the targetfile before we begin the copy). | public static int | copyFiles(File srcDir, Set srcFile, File dest) | public static void | copyFiles(File src, File dest) Recursively copy all files from one directory to another. | public static void | copyFiles(File src, FilenameFilter filter, File dest, boolean inSortedOrder, boolean overwrite) Recursively copy all files from one directory to another.
Parameters: src - File or directory to copy from. Parameters: filter - Filename filter to apply to src. | public static boolean | deleteDir(File dir) Deletes all files and subdirectories under dir.
Parameters: dir - true if all deletions were successful. | public static File[] | getFilesWithPrefix(File dir, String prefix) Get a list of all files in directory that have passed prefix.
Parameters: dir - Dir to look in. Parameters: prefix - Basename of files to look for. | public static FileFilter | getRegexpFileFilter(String regexp) Get a @link java.io.FileFilter that filters files based on a regular
expression.
Parameters: regexp - the regular expression the files must match. | public static String[] | getSortedDirContent(File src, FilenameFilter filter) Parameters: src - Directory of files to fetch. Parameters: filter - Filter to apply to filenames. | public static File | isReadable(File f) Test file exists and is readable. | public static boolean | isReadableWithExtensionAndMagic(File f, String uncompressedExtension, String magic) Parameters: f - File to test. | public static File | maybeRelative(File context, String path) Turn path into a File, relative to context (which may be ignored
if path is absolute). | public static String | readFileAsString(File file) Utility method to read an entire file as a String. | public static void | syncDirectories(File src, FilenameFilter filter, File tgt) Use for case where files are being added to src. | protected static void | workaroundCopyFile(File src, File dest) |
copyFile | public static boolean copyFile(File src, File dest, boolean overwrite) throws FileNotFoundException, IOException(Code) | | Copy the src file to the destination.
Parameters: src - Parameters: dest - Parameters: overwrite - If target file already exits, and this parameter istrue, overwrite target file (We do this by first deleting the targetfile before we begin the copy). True if the extent was greater than actual bytes copied. throws: FileNotFoundException - throws: IOException - |
copyFile | public static boolean copyFile(File src, File dest, long extent, boolean overwrite) throws FileNotFoundException, IOException(Code) | | Copy up to extent bytes of the source file to the destination
Parameters: src - Parameters: dest - Parameters: extent - Maximum number of bytes to copy Parameters: overwrite - If target file already exits, and this parameter istrue, overwrite target file (We do this by first deleting the targetfile before we begin the copy). True if the extent was greater than actual bytes copied. throws: FileNotFoundException - throws: IOException - |
copyFiles | public static void copyFiles(File src, File dest) throws IOException(Code) | | Recursively copy all files from one directory to another.
Parameters: src - file or directory to copy from. Parameters: dest - file or directory to copy to. throws: IOException - |
copyFiles | public static void copyFiles(File src, FilenameFilter filter, File dest, boolean inSortedOrder, boolean overwrite) throws IOException(Code) | | Recursively copy all files from one directory to another.
Parameters: src - File or directory to copy from. Parameters: filter - Filename filter to apply to src. May be null if nofiltering wanted. Parameters: dest - File or directory to copy to. Parameters: inSortedOrder - Copy in order of natural sort. Parameters: overwrite - If target file already exits, and this parameter istrue, overwrite target file (We do this by first deleting the targetfile before we begin the copy). throws: IOException - |
deleteDir | public static boolean deleteDir(File dir)(Code) | | Deletes all files and subdirectories under dir.
Parameters: dir - true if all deletions were successful. If a deletion fails, themethod stops attempting to delete and returns false. |
getFilesWithPrefix | public static File[] getFilesWithPrefix(File dir, String prefix)(Code) | | Get a list of all files in directory that have passed prefix.
Parameters: dir - Dir to look in. Parameters: prefix - Basename of files to look for. Compare is case insensitive. List of files in dir that start w/ passed basename. |
getRegexpFileFilter | public static FileFilter getRegexpFileFilter(String regexp)(Code) | | Get a @link java.io.FileFilter that filters files based on a regular
expression.
Parameters: regexp - the regular expression the files must match. the newly created filter. |
getSortedDirContent | public static String[] getSortedDirContent(File src, FilenameFilter filter)(Code) | | Parameters: src - Directory of files to fetch. Parameters: filter - Filter to apply to filenames. Files in directory sorted. |
isReadable | public static File isReadable(File f) throws IOException(Code) | | Test file exists and is readable.
Parameters: f - File to test. exception: IOException - If file does not exist or is not unreadable. |
isReadableWithExtensionAndMagic | public static boolean isReadableWithExtensionAndMagic(File f, String uncompressedExtension, String magic) throws IOException(Code) | | Parameters: f - File to test. True if file is readable, has uncompressed extension,and magic string at file start. exception: IOException - If file does not exist or is not readable. |
maybeRelative | public static File maybeRelative(File context, String path)(Code) | | Turn path into a File, relative to context (which may be ignored
if path is absolute).
Parameters: context - File context if path is relative Parameters: path - String path to make into a File File created |
readFileAsString | public static String readFileAsString(File file) throws IOException(Code) | | Utility method to read an entire file as a String.
Parameters: file - File as String. throws: IOException - |
syncDirectories | public static void syncDirectories(File src, FilenameFilter filter, File tgt) throws IOException(Code) | | Use for case where files are being added to src. Will break off copy
when tgt is same as src.
Parameters: src - Source directory to copy from. Parameters: tgt - Target to copy to. Parameters: filter - Filter to apply to files to copy. throws: IOException - |
|
|