|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ow2.util.file.FileUtils
public final class FileUtils
This class manages operation done many times on files, like copying them.
| Method Summary | |
|---|---|
static String |
calculateChecksum(File file,
String algorithm)
For a given file, calculate its checksum using a given algorithm. |
static boolean |
chmod(File file,
String mode)
Change the permissions of a given file by using chmod. |
static void |
close(Closeable... closeables)
Close all given Closeable instances. |
static void |
copyDirectory(File src,
File dest)
Copy a directory recursively. |
static File |
copyDirectory(File src,
File dest,
boolean override)
Copy a directory recursively. |
static void |
copyDirectory(String src,
String dest)
Copy a directory recursively. |
static File |
copyFile(File src,
File dest)
Copy a file and return its copy. |
static File |
copyFile(String src,
String dest)
Copy a file and return its copy. |
static boolean |
delete(File f)
|
static boolean |
delete(String path)
|
static void |
dump(InputStream in,
File entryFile)
Write the given input stream in the given file. |
static Collection<File> |
find(File directory,
FileFilter fileFilter,
boolean recursive)
|
static void |
flush(Flushable... flushables)
Flush all given Flushable instances. |
static String |
getMode(File file)
Return the mode for a given file. |
static String |
lastModifiedFileName(File file)
For a given file, get the shorter name containing the last modification date. |
static void |
print(File txtFile)
Print a text file in standard output. |
static void |
print(File txtFile,
PrintWriter printWriter)
Print a text file in a print writer. |
static String |
readFile(String path)
Return the string contained in the given file, by using the default charset. |
static String |
readFile(String path,
Charset charset)
Return the string contained in the given file, by using the given charset to decode it. |
static void |
unpack(JarFile packedJar,
File dest)
Unpack the source archive in a given directory. |
static void |
updateAttributesInManifest(String jarName,
Map<String,String> attributes)
Change the attribute value in a jar file (and update file if required). |
static void |
updateManifestAttributesInJarArchive(File file,
Map<String,String> attributes)
Change the attribute value in a jar file (and update file if required). |
static void |
updateManifestAttributesInJarDirectory(File file,
Map<String,String> attributes)
Change the attribute value in a jar file (and update directory if required). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void unpack(JarFile packedJar,
File dest)
throws FileUtilsException
packedJar - source JarFile to be unpackeddest - the destination folder
FileUtilsException - When unpack fails
public static void dump(InputStream in,
File entryFile)
throws FileUtilsException
in - the inputStream to copy.entryFile - the file where the inputStream must be dumped.
FileUtilsException - if the dump failed.
public static void print(File txtFile,
PrintWriter printWriter)
throws FileUtilsException
txtFile - the text fileprintWriter - the print writer
FileUtilsException - if error occurs
public static void print(File txtFile)
throws FileUtilsException
txtFile - the text file
FileUtilsException - if error occurs
public static File copyFile(String src,
String dest)
throws FileUtilsException
src - source filedest - dest file
FileUtilsException - if the copy of the file failed
public static File copyFile(File src,
File dest)
throws FileUtilsException
src - source filedest - dest file
FileUtilsException - if the copy of the file failedpublic static boolean delete(String path)
path - file/directory to be deleted
public static boolean delete(File f)
f - file/directory to be deleted
public static void copyDirectory(String src,
String dest)
throws FileUtilsException
src - source directorydest - dest directory
FileUtilsException - if the copy of the directory failed
public static File copyDirectory(File src,
File dest,
boolean override)
throws FileUtilsException
src - source directorydest - dest directoryoverride - true if the destination directory is overridden
FileUtilsException - if the copy of the directory failed
public static void copyDirectory(File src,
File dest)
throws FileUtilsException
src - source directorydest - dest directory
FileUtilsException - if the copy of the directory failed
public static void updateAttributesInManifest(String jarName,
Map<String,String> attributes)
throws FileUtilsException
jarName - output jar fileattributes - a list of attributes (name <-> value)
FileUtilsException - if the manifest is not updated.
public static void updateManifestAttributesInJarDirectory(File file,
Map<String,String> attributes)
throws FileUtilsException
file - input archiveattributes - a list of attributes (name <-> value)
FileUtilsException - if the given file is not a directory (it may be an archive)
or if the inner Manifest opened/updated.
public static void updateManifestAttributesInJarArchive(File file,
Map<String,String> attributes)
throws FileUtilsException
file - input archiveattributes - a list of attributes (name <-> value)
FileUtilsException - if the given file is not a file (it may be a directory)
or if the given jar cannot be opened/updated/closed.public static void close(Closeable... closeables)
closeables - list of Closeable instance to be closed.public static void flush(Flushable... flushables)
flushables - list of Flushable instance to be closed.
public static final boolean chmod(File file,
String mode)
file - a filemode - a mode
public static final Collection<File> find(File directory,
FileFilter fileFilter,
boolean recursive)
public static final String getMode(File file)
file - a file
public static String lastModifiedFileName(File file)
throws FileUtilsException
file - the given file to analyze to get the file name and the last
modification date
FileUtilsException - Thrown if the given file cannot be retrieved
public static String calculateChecksum(File file,
String algorithm)
throws FileUtilsException
file - The file to checkalgorithm - The checksum algorithm
FileUtilsException - If the checksum cannot be calculated
public static String readFile(String path,
Charset charset)
throws IOException
path - the file pathcharset - the charset to decode the file
IOException - if some I/O errors occur
public static String readFile(String path)
throws IOException
path - the file path
IOException - if some I/O errors occur
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||