|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectphelps.io.Files
Extensions to File
.
File
constructors: getFile(String)
, getCanonicalFile(String)
, getFuzzyFile(File, String)
isCompressed(String)
, isBackup(String)
getSuffix(String)
, getRoot(String)
relative(File, File)
, shortpath(File, File)
glob(String)
toByteArray(File)
, copy(File, File)
, delete(File)
, secureDelete(File)
Field Summary | |
---|---|
static int |
BUFSIZ
Common size of disk blocks at the time of release (this can increase from release to release). |
static java.util.Comparator<java.io.File> |
DICTIONARY_CASE_INSENSITIVE_ORDER
Comparator that sorts filenames ( File.getName() ), not full path, by {@link phelps.lang.Strings#DICTIONARY_CASE_INSENSITIVE_ORDER. |
Method Summary | |
---|---|
static void |
copy(java.io.File filein,
java.io.File fileout)
Copies filein to fileout, creating parent directories as needed. |
static boolean |
delete(java.io.File dir)
Delete directory, including all files and subdirectories. |
static java.io.File |
getCanonicalFile(java.lang.String path)
Like java.io.File#getCanonicalFile(String) but also expands ~ to users home directory (as given by the user.home property). |
static java.lang.String |
getEncoding(java.lang.String path)
Returns HTTP Content-Encoding (compression type) as guessed from path's suffix. |
static java.io.File |
getFile(java.lang.String path)
Like File.File(String) but also expands ~user to users home directory (as given by the user.home property). |
static java.io.File |
getFuzzyFile(java.io.File base,
java.lang.String path)
Returns existing file (not directory), looking around a little if necessary: (UNIX) getCanonicalFile(String)
(WWW) if points to directory, tries adding "index.html"
(compression) adding or removing a compression suffix
If no existing file can be found, returns same as getCanonicalFile(String) . |
static java.lang.String |
getRoot(java.lang.String filename)
Returns filename with suffix, if any, chopped off. |
static java.lang.String |
getSuffix(java.io.File file)
|
static java.lang.String |
getSuffix(java.lang.String filename)
Returns the portion of filename after and exclusive of the last dot ("."). |
static java.lang.String |
getTail(java.lang.String path)
|
static java.io.File[] |
glob(java.lang.String pattern)
Returns array of File's matching UNIX glob pattern, with the extension that ** searches the current directory and all subdirectories. |
static boolean |
isBackup(java.lang.String filename)
Returns true if filename is a backup file (e.g., end with ".bkup", with possible additional compression suffix). |
static boolean |
isCompressed(java.lang.String filename)
Returns true if filename has a compression suffix for a type we can handle, which are .gz , .Z , .bzip2 /.bz2 . |
static java.lang.String |
relative(java.io.File base,
java.io.File file)
Returns path of file relative to base. |
static boolean |
renameTo(java.io.File file,
java.io.File dest)
Like File.renameTo(File) , except guaranteed to work across file-systems, copying if necessary. |
static boolean |
secureDelete(java.io.File file)
Securely deletes a file by first overwriting it with random data several times. |
static java.lang.String |
shortpath(java.io.File base,
java.io.File file)
Returns the shortest path: relative to base, relative to user home directory, or absolute. |
static byte[] |
toByteArray(java.io.File file)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.Comparator<java.io.File> DICTIONARY_CASE_INSENSITIVE_ORDER
File.getName()
), not full path, by {@link phelps.lang.Strings#DICTIONARY_CASE_INSENSITIVE_ORDER.
public static final int BUFSIZ
Method Detail |
---|
public static java.io.File getFile(java.lang.String path)
File.File(String)
but also expands ~user
to users home directory (as given by the user.home
property).
public static java.io.File getCanonicalFile(java.lang.String path) throws java.io.IOException
java.io.File#getCanonicalFile(String)
but also expands ~
to users home directory (as given by the user.home
property).
java.io.IOException
public static java.io.File getFuzzyFile(java.io.File base, java.lang.String path) throws java.io.IOException
getCanonicalFile(String)
getCanonicalFile(String)
.
java.io.IOException
public static java.lang.String relative(java.io.File base, java.io.File file)
public static java.lang.String shortpath(java.io.File base, java.io.File file)
public static java.lang.String getRoot(java.lang.String filename)
public static java.lang.String getTail(java.lang.String path)
public static java.lang.String getSuffix(java.io.File file)
public static java.lang.String getSuffix(java.lang.String filename)
public static boolean renameTo(java.io.File file, java.io.File dest)
File.renameTo(File)
, except guaranteed to work across file-systems, copying if necessary.
public static boolean isCompressed(java.lang.String filename)
.gz
, .Z
, .bzip2
/.bz2
.
public static java.lang.String getEncoding(java.lang.String path)
public static boolean isBackup(java.lang.String filename)
public static java.io.File[] glob(java.lang.String pattern) throws java.io.IOException
**
searches the current directory and all subdirectories.
A glob pattern is related to a regular expression as follows:
the glob *
is equivalent to regexp .*
., ?
to .
, and {one,two}
to {(one|two)
.
Also, the ~
, .
, and ..
strings have their same meaning as in getFile(String)
.
java.io.IOException
public static byte[] toByteArray(java.io.File file) throws java.io.IOException
java.io.IOException
public static void copy(java.io.File filein, java.io.File fileout) throws java.io.IOException
java.io.IOException
public static boolean delete(java.io.File dir)
public static boolean secureDelete(java.io.File file) throws java.io.IOException
true
iff successful
java.io.IOException
|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |