|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFileX
@ThreadSafe public final class FileX
File utilities.
Field Summary | |
---|---|
static Pattern |
BODY_DOTX_PATTERN
Pattern to split a filename (or path) into two groups: body and dot-extension. |
Method Summary | |
---|---|
static void |
copyAs(File target,
File source)
|
static void |
copyAs(File target,
File source,
FileFilter fileFilter)
Copies a file to a new file named as specified. |
static void |
copyTo(File targetDirectory,
File source)
|
static void |
copyTo(File targetDirectory,
File source,
FileFilter fileFilter)
|
static boolean |
createNewDirectory(File directory)
Atomically creates a new, empty directory if and only if the directory does not yet exist. |
static boolean |
deleteRecursive(File fileOrDirectory)
As per File.delete() except it will work with non-empty directories. |
static boolean |
deleteRecursiveFrom(File directory)
Same as deleteRecursive() ,
except it works only on the contents of the specified directory. |
static boolean |
renameFrom(File oldFile,
File newFile)
Tries hard to rename a file, despite bug 6213298. |
static boolean |
renameFromDefaultsToCopy(File oldFile,
File newFile)
First tries renameFrom, and failing that, makes a copy. |
static File |
tempDirectory()
Returns a new instance of file system's temporary directory, as defined by System property 'java.io.tmpdir'. |
static boolean |
testsCaseSensitive()
Tests whether or not the file system is case sensitive, and returns true iff it is. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Pattern BODY_DOTX_PATTERN
The extension group (2) will either include the preceding dot '.', or it will be empty. It will not be null.
Method Detail |
---|
public static void copyAs(File target, File source) throws IOException
target
- pathname to create as copy (will be overwritten if it already exists)source
- file or directory to copy
(directory contents are recursively copied using copyTo
)
IOException
public static void copyAs(File target, File source, FileFilter fileFilter) throws IOException
target
- pathname to create as copy (will be overwritten if it already exists)source
- file or directory to copy
(directory contents are recursively copied
using copyTo
)fileFilter
- to use, if the source is a directory
(filter is applied to contents of directory,
and recursively to contents of any sub-directories that themselves pass the filter)
IOException
public static void copyTo(File targetDirectory, File source) throws IOException
targetDirectory
- in which to make copy (must already exist)source
- file or directory to copy (directories are recursively copied)
overwriting any existing file or directory of the same name
IOException
public static void copyTo(File targetDirectory, File source, FileFilter fileFilter) throws IOException
targetDirectory
- in which to make copy (must already exist)source
- file or directory to copy (directories are recursively copied)
overwriting any existing file or directory of the same namefileFilter
- to use, if the source is a directory
(filter is applied to contents of directory,
and recursively to contents of any sub-directories that themselves pass the filter)
IOException
public static boolean createNewDirectory(File directory) throws IOException
directory
- to create if it does not already exist
IOException
- if the directory did not exist, and could not be createdpublic static boolean deleteRecursive(File fileOrDirectory)
fileOrDirectory
- to delete
SecurityException
- if the application does not have permission to delete the fileOrDirectorypublic static boolean deleteRecursiveFrom(File directory)
deleteRecursive()
,
except it works only on the contents of the specified directory.
directory
- whose contents to delete
SecurityException
- if the application does not have permission to delete the fileOrDirectorypublic static boolean testsCaseSensitive()
public static boolean renameFrom(File oldFile, File newFile)
public static boolean renameFromDefaultsToCopy(File oldFile, File newFile) throws IOException
IOException
public static File tempDirectory()
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |