public class FileUtil extends Object
| Constructor and Description |
|---|
FileUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
copy(File src,
File dst,
boolean overwriteExisting,
boolean quiet) |
static boolean |
copy(String source,
String dest,
boolean overwriteExisting) |
static boolean |
copy(String source,
String dest,
boolean overwriteExisting,
boolean quiet) |
static boolean |
extractZip(File zipfile,
File targetDir)
As of release 0.7.12, any files inside the zip that have a .jar.pack or .war.pack suffix
are transparently unpacked to a .jar or .war file using unpack200.
|
static boolean |
extractZip(File zipfile,
File targetDir,
int logLevel)
Warning - do not call any new classes from here, or
update will crash the JVM.
|
static boolean |
isPack200Supported()
Public since 0.8.3
|
static void |
main(String[] args)
Usage: FileUtil (delete path | copy source dest | rename from to | unzip path.zip)
|
static void |
readFile(String path,
String root,
OutputStream out)
Dump the contents of the given path (relative to the root) to the output
stream.
|
static String |
readTextFile(String filename,
int maxNumLines,
boolean startAtBeginning)
Read in the last few lines of a (newline delimited) textfile, or null if
the file doesn't exist.
|
static boolean |
rename(File from,
File to)
Try to rename, if it doesn't work then copy and delete the old.
|
static boolean |
rmdir(File target,
boolean failIfNotEmpty)
Delete the path as well as any files or directories underneath it.
|
static boolean |
rmdir(String path,
boolean failIfNotEmpty)
Delete the path as well as any files or directories underneath it.
|
static boolean |
verifyZip(File zipfile)
Verify the integrity of a zipfile.
|
public static boolean copy(File src, File dst, boolean overwriteExisting, boolean quiet)
quiet - don't log fails to wrapper log if truepublic static boolean copy(String source, String dest, boolean overwriteExisting)
public static boolean copy(String source, String dest, boolean overwriteExisting, boolean quiet)
quiet - don't log fails to wrapper log if truepublic static boolean extractZip(File zipfile, File targetDir)
public static boolean extractZip(File zipfile, File targetDir, int logLevel)
logLevel - Log.WARN, etc.public static boolean isPack200Supported()
public static void main(String[] args)
public static void readFile(String path, String root, OutputStream out) throws IOException
IOExceptionpublic static String readTextFile(String filename, int maxNumLines, boolean startAtBeginning)
startAtBeginning - if true, read the first maxNumLines, otherwise read
the last maxNumLinesmaxNumLines - max number of lines (or -1 for unlimited)public static boolean rename(File from, File to)
public static final boolean rmdir(File target, boolean failIfNotEmpty)
target - the file or directory being deletedfailIfNotEmpty - if true, do not delete anything if the directory
is not empty (and return false)public static final boolean rmdir(String path, boolean failIfNotEmpty)
path - path to the directory being deletedfailIfNotEmpty - if true, do not delete anything if the directory
is not empty (and return false)public static boolean verifyZip(File zipfile)