|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eodisp.util.FileUtil
public class FileUtil
Collection of file and path related functions.
| Constructor Summary | |
|---|---|
FileUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
compressPath(java.lang.String path,
int maxPathLength)
Returns a compressed version of the path. |
static void |
copy(java.io.InputStream in,
java.io.File outFile)
Copies the given input stream to a file. |
static void |
copyFile(java.io.File src,
java.io.File dst)
A convenient method to copy the content of a file to another file. |
static void |
createFile(java.io.File file,
long size)
Creates a file on the local file system with the given file size. |
static java.io.File |
createTempDir(java.lang.String prefix,
java.lang.String postfix,
java.io.File dir)
Creates an empty temporary directory. |
static boolean |
deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir. |
static java.lang.String |
getRelativePath(java.io.File fromDir,
java.io.File toFileOrDir)
Returns the path of a file or directory relative to a directory, in native format. |
static java.io.File |
getTempDir()
Returns the operation system specific temp directory as a File. |
static boolean |
isInside(java.io.File file,
java.io.File ascendant)
Returns true if file is inside ascendant,
otherwise returns false. |
static boolean |
isInsideOrEquals(java.io.File file,
java.io.File ascendant)
Returns true if file is inside ascendant or
file is the same as the ascendant,
otherwise returns false. |
static byte[] |
loadByteArray(java.io.InputStream in)
|
static byte[] |
loadFileToByteArray(java.io.File file)
|
static java.lang.String |
loadString(java.io.InputStream in,
java.lang.String charset)
|
static void |
mergeFilesToDest(java.io.File src,
java.io.File dest)
Convenient method to merge the content of two files together. |
static java.io.File |
mergeFileToNew(java.io.File src1,
java.io.File src2,
java.io.File result)
Convenient method to merge the content of two files together. |
static java.lang.String |
pathPatternToPerl5Regex(java.lang.String text)
Converts UN*X style path to Perl 5 regular expression. |
static java.lang.String |
pathToUnixStyle(java.lang.String path)
Brings the path to UNI*X style format, so that it can be handled with path pattern handling functions. |
static java.lang.String |
removeSlashPrefix(java.lang.String path)
|
static java.io.File |
resolveRelativeUnixPath(java.io.File root,
java.io.File wd,
java.lang.String path)
Resolves relative UN*X path based on given root and working directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileUtil()
| Method Detail |
|---|
public static java.io.File getTempDir()
"java.io.tmpdir"
Java system property.
System.getProperty(java.lang.String)
public static java.lang.String getRelativePath(java.io.File fromDir,
java.io.File toFileOrDir)
throws java.io.IOException
java.io.IOException - if the two paths has no common parent directory (such as
C:\foo.txt and D:\foo.txt), or
the the paths are malformed.
public static void copyFile(java.io.File src,
java.io.File dst)
throws java.io.IOException
The destination file will be overridden if it already exists.
src - The source file with the content to be copied.dest - The destination file to which the content of the source file
should be copied. Will be created if it does not exist.
java.io.IOException - If the operation fails for any reason, this exception will be
thrown to indicate the error. See the documentation of the
exception for more information about possible errors.
public static java.io.File mergeFileToNew(java.io.File src1,
java.io.File src2,
java.io.File result)
throws java.io.IOException
src1 - The first file. Its content will be transferred to the result
file.src2 - The second file. Its content will be transferred to the result
file.result - The file to which the merged content should be written.
java.io.IOException - If the operation fails for any reason, this exception will be
thrown to indicate the error. See the documentation of the
exception for more information about possible errors.
public static void mergeFilesToDest(java.io.File src,
java.io.File dest)
throws java.io.IOException
src - The first file. Its content will be transferred to the dest
file.dest - The second file. This will be the file with the merged
content.
java.io.IOException - If the operation fails for any reason, this exception will be
thrown to indicate the error. See the documentation of the
exception for more information about possible errors.
public static void copy(java.io.InputStream in,
java.io.File outFile)
throws java.io.IOException
in - the input stream to copy fromoutFile - the file to write the stream to
java.io.IOException - if an IO Error occurs
public static boolean isInsideOrEquals(java.io.File file,
java.io.File ascendant)
file is inside ascendant or
file is the same as the ascendant,
otherwise returns false.
public static boolean isInside(java.io.File file,
java.io.File ascendant)
file is inside ascendant,
otherwise returns false.
public static java.io.File resolveRelativeUnixPath(java.io.File root,
java.io.File wd,
java.lang.String path)
throws java.io.IOException
root - root directorywd - working directory (current directory)path - path in UN*X format
java.io.IOException
public static java.lang.String compressPath(java.lang.String path,
int maxPathLength)
/foo/ba.../baaz.txt instead of
/foo/bar/blah/blah/blah/baaz.txt.
path - the path to compress. Either native or UNIX format.maxPathLength - the maximum length of the result. Must be at least 4.public static java.lang.String pathToUnixStyle(java.lang.String path)
public static java.lang.String removeSlashPrefix(java.lang.String path)
public static java.lang.String pathPatternToPerl5Regex(java.lang.String text)
*, ?)
it understands **, that is the same as in Jakarta Ant. It
assumes that the paths what you will later match with the pattern are
always starting with slash (they are absolute paths to an imaginary
base).
public static java.lang.String loadString(java.io.InputStream in,
java.lang.String charset)
throws java.io.IOException
java.io.IOException
public static byte[] loadByteArray(java.io.InputStream in)
throws java.io.IOException
java.io.IOException
public static byte[] loadFileToByteArray(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static boolean deleteDir(java.io.File dir)
dir. Returns
true if all deletions were successful. If a deletion fails, the method
stops attempting to delete and returns false.
dir -
public static java.io.File createTempDir(java.lang.String prefix,
java.lang.String postfix,
java.io.File dir)
throws java.io.IOException
prefix - The prefix string to be used in generating the directory's
name; must be at least three characters longpostfix - The suffix string to be used in generating the directory's
name; may be null, in which case the suffix
".tmp" will be useddir - The directory in which the temp directory is to be created, or
null if the default temporary-file directory is
to be used as the parent directory.
java.io.IOException - If a directory could not be created
java.lang.SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String)
method does not allow a file to be created
public static void createFile(java.io.File file,
long size)
throws java.io.IOException
file - the file to be createdsize - the size of the file in bytes
java.io.IOException - if the file could not be created
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||