|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.evanmclean.evlib.io.Files
public final class Files
Perform various file related operations. Also see Folders.
| Method Summary | |
|---|---|
static void |
copy(File from,
File to)
Efficient file copy. |
static void |
copy(File from,
File to,
boolean preserve_date)
Efficient file copy. |
static void |
del(File path)
Deletes the file if it exists. |
static boolean |
del(File path,
boolean quietly)
Deletes the file if it exists. |
static boolean |
delhard(File path)
Deletes the file if it exists, trying to make the file and/or the parent folder writable in order to do so. |
static File |
getCanonicalFile(File path)
Returns the canonical form of an abstract pathname. |
static String |
getCanonicalPath(File path)
Returns the canonical pathname string of an abstract pathname. |
static boolean |
isEmpty(File path)
Checks the path specified is a zero length file, an empty folder or does not exist. |
static boolean |
isNotEmpty(File path)
Checks the path specified is a zero length file, an empty folder or does not exist. |
static void |
move(File from,
File to)
Efficient file move. |
static void |
move(File from,
File to,
boolean preserve_date)
Efficient file move. |
static void |
rename(File from,
File to)
Renames a file or folder. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void copy(File from,
File to)
throws IOException
Efficient file copy. The last modified date is preserved.
Uses the java.nio.channels logic to efficiently copy a file without having to create ancillary temporary buffers and such.
from - Source file to copy.to - Destination file that will be overwitten.
IOException
public static void copy(File from,
File to,
boolean preserve_date)
throws IOException
Efficient file copy.
Uses the java.nio.channels logic to efficiently copy a file without having to create ancillary temporary buffers and such.
from - Source file to copy.to - Destination file that will be overwritten.preserve_date - If true then the last modified date is preserved.
IOException
public static void del(File path)
throws IOException
Folders.del(File) to delete a folder and its contents. This is
basically the same as delhard(File) but throws an exception on
error instead of returning false.
path - The file to delete.
IOException - If unable to delete the file.
public static boolean del(File path,
boolean quietly)
throws IOException
Folders.del(File) to delete a folder and its contents. This is
basically the same as delhard(File) but throws an exception on
error instead of returning false.
path - The file to delete.quietly - Only through an IO exception if quietly is
false.
IOException - If unable to delete the file (and quietly is
false).public static boolean delhard(File path)
Folders.del(File) to delete a folder and its contents.
path - The file to delete.
public static File getCanonicalFile(File path)
File.getCanonicalFile() which will throw a runtime exception
on error instead of an IOException.
path -
path
is null then null is returned.
UnhandledException - Runtime wrapper around the IOException if it occurred.public static String getCanonicalPath(File path)
File.getCanonicalPath() which will throw a runtime
exception on error instead of an IOException.
path -
path is null
then null is returned.
UnhandledException - Runtime wrapper around the IOException if it occurred.
public static boolean isEmpty(File path)
throws IOException
path - The path the check.
IOException - If folder does not represent a file or a folder.
public static boolean isNotEmpty(File path)
throws IOException
path - The path the check.
IOException - If folder does not represent a file or a folder.
public static void move(File from,
File to)
throws IOException
Efficient file move. The last modified date is preserved.
Tries to do a rename, and if that fails calls
copy(File, File, boolean) then del(File) to efficiently
and effectively move the file.
from - Source file to move.to - Destination file that will be overwritten.
IOException
public static void move(File from,
File to,
boolean preserve_date)
throws IOException
Efficient file move.
Tries to do a rename, and if that fails calls
copy(File, File, boolean) then del(File) to efficiently
and effectively move the file.
from - Source file to move.to - Destination file that will be overwritten.preserve_date - If true then the last modified date is preserved.
IOException
public static void rename(File from,
File to)
throws IOException
File.renameTo(File) but throws an exception on error instead of
returning false.
from - The file or folder to rename.to - What we are renaming the file or folder to.
IOException - If unable to rename the file or folder.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||