public abstract class Files
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
private |
Files() |
| Modifier and Type | Method and Description |
|---|---|
static java.io.File |
canonicalizeFile(java.io.File file) |
static java.lang.String |
canonicalizePathname(java.lang.String pathname)
Converts 'pathname' into the canonical OS form.
|
static java.io.File |
createTempFile(java.io.File parentDir,
java.lang.String prefix,
java.lang.String extension)
A slightly stricter version of File.createTempFile() in J2SDK 1.3: it requires
that the caller provide an existing parent directory for the temp file.
|
static java.lang.String |
getFileExtension(java.io.File file)
Invariant: (getFileName (file) + getFileExtension (file)).equals (file.getName ()).
|
static java.lang.String |
getFileName(java.io.File file)
Invariant: (getFileName (file) + getFileExtension (file)).equals (file.getName ()).
|
static java.io.File |
newFile(java.io.File dir,
java.io.File file) |
static java.io.File |
newFile(java.io.File dir,
java.lang.String file) |
static java.io.File |
newFile(java.lang.String dir,
java.lang.String file) |
static java.io.File[] |
pathToFiles(java.lang.String[] path,
boolean canonical)
Converts an array of path segments to an array of Files.
|
static java.lang.String[] |
readFileList(java.io.File atfile)
No duplicate elimination.
|
static boolean |
renameFile(java.io.File source,
java.io.File target,
boolean overwrite)
Renames 'source' to 'target' [intermediate directories are created if necessary].
|
public static java.lang.String[] readFileList(java.io.File atfile)
throws java.io.IOException
atfile - java.io.IOExceptionpublic static java.io.File[] pathToFiles(java.lang.String[] path,
boolean canonical)
canonicalizePathname(java.lang.String)
before they are compared for equality
public static java.lang.String canonicalizePathname(java.lang.String pathname)
public static java.io.File canonicalizeFile(java.io.File file)
public static java.lang.String getFileName(java.io.File file)
file - File input file descriptor [must be non-null]java.lang.IllegalArgumentException - if 'file' is nullpublic static java.lang.String getFileExtension(java.io.File file)
file - File input file descriptor [must be non-null]java.lang.IllegalArgumentException - if 'file' is nullpublic static java.io.File newFile(java.io.File dir,
java.io.File file)
dir - [null is ignored]file - [absolute overrides 'dir']public static java.io.File newFile(java.io.File dir,
java.lang.String file)
dir - [null is ignored]file - [absolute overrides 'dir']public static java.io.File newFile(java.lang.String dir,
java.lang.String file)
dir - [null is ignored]file - [absolute overrides 'dir']public static boolean renameFile(java.io.File source,
java.io.File target,
boolean overwrite)
source - file descriptor [file must exist]target - target file descriptor [an existing target may get deleted
if 'overwrite' is true]overwrite - if 'true', forces an existing target to be deletedjava.lang.IllegalArgumentException - if 'source' is null or file does not existjava.lang.IllegalArgumentException - if 'target' is nullpublic static java.io.File createTempFile(java.io.File parentDir,
java.lang.String prefix,
java.lang.String extension)
throws java.io.IOException
MT-safety: if several threads use this API concurrently, the temp files created are guaranteed to get created without any collisions and correspond to files that did not exist before. However, if such a temp file is deleted at a later point, this method may reuse its file name. These MT-safety guarantees do not hold if files are created in the same directory outside of this method.
parentDir - parent dir for the temp file [may not be null and must exist]prefix - prefix pattern for the temp file name [only the first 3
chars are guaranteed to be used]extension - pattern for the temp file name [null is equivalient to
".tmp"; this is always normalized to start with "."; only the first 3
non-"." chars are guaranteed to be used]java.io.IOException - if a temp file could not be created