|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.io.FileLib
public class FileLib
General handy file tools.
| Field Summary | |
|---|---|
static int |
BUFFER_SIZE
|
static java.text.SimpleDateFormat |
timestampFormat
|
| Constructor Summary | |
|---|---|
FileLib()
|
|
| Method Summary | |
|---|---|
static java.io.File |
canonicalize(java.io.File victim)
|
static long |
checksum(java.io.File victim)
Generates a checksum for the given file. |
static long |
copy(java.io.File source,
java.io.File dest)
|
static long |
copy(java.io.File source,
java.io.File dest,
FileActivityListener nosy)
|
static long |
copy(java.lang.String source,
java.lang.String dest)
|
static void |
copyTree(java.io.File source,
java.io.File destinationDir)
Copies an entire directory tree. |
static void |
copyTree(java.io.File source,
java.io.File destinationDir,
FileActivityListener nosy)
Copies an entire directory tree. |
static void |
copyTreeContents(java.io.File source,
java.io.File destinationDir)
Copies an entire directory tree. |
static void |
copyTreeContents(java.io.File source,
java.io.File destinationDir,
FileActivityListener nosy)
|
static void |
copyTreeNoOverwrite(java.io.File source,
java.io.File destination)
this will copy two trees making sure not to overwrite any exsisting info |
static int |
countFilesInTree(java.io.File dir)
|
static java.io.File |
createDir(java.io.File dir,
java.lang.String filename)
Creates a File object for a subdirectory of an existing directory, unscrubbing the name and making the directory if necessary. |
static java.io.File |
createDir(java.lang.String filename)
Creates a File object for a directory, unscrubbing the string and making the directory if needed. |
static java.io.File |
createFile(java.io.File dir,
java.lang.String filename)
Creates a File object for an existing directory, unscrubbing the name. |
static java.io.File |
createFile(java.lang.String filename)
Creates a File object, unscrubbing the string. |
static java.io.File |
createFileMakeDir(java.io.File dir,
java.lang.String filename)
Creates a File object for an existing directory, unscrubbing the name and making the parent directory if necessary. |
static java.io.File |
createFileMakeDir(java.lang.String filename)
Creates a File object, unscrubbing the string and making the parent if necessary. |
static java.io.File |
createTempDir()
Tries to create a temporary directory by creating a temporary file, then deleting it and making a directory. |
static java.io.File |
createTempFile(java.io.File file)
Creates a tempfile for the given file, by appending ".temp" to its name. |
static java.io.File |
createTempFile(java.lang.String filename)
Creates a tempfile for the given file, by appending ".temp" to its name. |
static void |
deleteContents(java.io.File dir)
Deletes contents of dir. |
static void |
deleteFileAndParentIfEmpty(java.io.File victim)
Deletes the given file. |
static void |
deleteTree(java.io.File file)
rm -rf file |
static void |
eject(java.io.File root)
|
static long |
fileCopy(java.io.File source,
java.io.File dest)
Binary copies a file from source to destination. |
static java.io.File |
getInstallRoot()
Root directory of Partner install. |
static boolean |
isBeneath(java.io.File filet,
java.io.File root)
Returns true if the given file is the root or a file "beneath" (a subdirectory of or in a subdirectory of) the root. |
static boolean |
isInsideInstall(java.io.File filet)
Returns true if the given file is the root or a file "beneath" (a subdirectory of or in a subdirectory of) the root. |
static boolean |
isSubpath(java.lang.String path)
Returns true if the file path is a sub path - i.e., no relative parent references or absolute references. |
static java.lang.String[] |
listFilesRemoveExtension(java.io.File dir,
java.lang.String extension)
Returns a list of files with the given extension, minus the extension. |
static byte[] |
loadFile(java.io.File source)
Binary copies a file from source into a byte array in memory. |
static java.lang.String |
loadFileAsString(java.io.File file)
Slurps a text file in as a single big String. |
static long[] |
loadFileOfLongs(java.io.File source)
Binary copies a file from source into a long array in memory. |
static byte[] |
loadStream(java.io.InputStream source)
Identical to loadFile(). |
static void |
makeDirsFor(java.io.File file)
Creates parent directories for a file object. |
static java.lang.String |
makeValidFilename(java.lang.String source)
|
static void |
mount(java.io.File root)
Attempt to mount a filesystem. |
static void |
move(java.io.File from,
java.io.File to)
|
static java.io.File |
moveToTempFile(java.io.File original)
Moves a file to a tempfile, ensuring deletion happens etc. |
static java.lang.String |
relativePath(java.io.File root,
java.io.File filet)
Returns the path relative to some root. |
static java.lang.String |
removeExtension(java.lang.String filename)
Returns everything in the string up to the last period (.); handy for chopping off extensions. |
static java.lang.String |
removeFileName(java.lang.String filename)
Just returns the directory path (not the filename). |
static java.lang.String |
removeParentPath(java.lang.String parent,
java.lang.String victim)
Removes a parent path from a full path. |
static java.lang.String |
removePathAndExtension(java.lang.String filename)
Returns everything in the string up to the last period (.); handy for chopping off extensions. |
static void |
removeTree(java.io.File victim)
Removes an entire directory tree. |
static void |
removeTree(java.io.File victim,
FileActivityListener nosy)
|
static void |
removeTreeContents(java.io.File victim)
Removes the contents of an entire directory tree. |
static java.io.File |
reserveTempFile(java.io.File original)
Creates a tempfile for the given file, by appending ".temp" to its name; deletes any existing. |
static void |
saveFile(byte[] contents,
java.io.File source)
Binary copies a byte array in memory to a file. |
static void |
saveFile(java.lang.String contents,
java.io.File source)
Saves a string to a file. |
static java.lang.String |
separatorToSlash(java.lang.String filename)
Scrubs a string, turning native File.separator strings into Unix-style slashes. |
static java.lang.String |
slashToSeparator(java.lang.String filename)
Unscrubs a string, turning Unix-style slashes into native File.separator strings. |
static java.lang.String |
timestampFileName(java.lang.String filename)
Adds a date and timestamp to the filename, just before the extension. |
static void |
unmount(java.io.File root)
Attempt to unmount a filesystem. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int BUFFER_SIZE
public static java.text.SimpleDateFormat timestampFormat
| Constructor Detail |
|---|
public FileLib()
| Method Detail |
|---|
public static java.io.File getInstallRoot()
public static boolean isInsideInstall(java.io.File filet)
throws java.io.IOException
java.io.IOException
public static boolean isBeneath(java.io.File filet,
java.io.File root)
public static void mount(java.io.File root)
throws java.io.IOException
java.io.IOException
public static void unmount(java.io.File root)
throws java.io.IOException
java.io.IOException
public static void eject(java.io.File root)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String slashToSeparator(java.lang.String filename)
public static java.lang.String separatorToSlash(java.lang.String filename)
public static boolean isSubpath(java.lang.String path)
public static java.io.File createFile(java.lang.String filename)
public static java.io.File createFile(java.io.File dir,
java.lang.String filename)
public static java.io.File createFileMakeDir(java.lang.String filename)
throws java.io.IOException
java.io.IOException
public static void makeDirsFor(java.io.File file)
throws java.io.IOException
java.io.IOException
public static java.io.File createFileMakeDir(java.io.File dir,
java.lang.String filename)
throws java.io.IOException
java.io.IOExceptionpublic static java.io.File createDir(java.lang.String filename)
public static java.io.File createDir(java.io.File dir,
java.lang.String filename)
public static void deleteContents(java.io.File dir)
throws java.io.IOException
java.io.IOException
public static void deleteTree(java.io.File file)
throws java.io.IOException
file -
java.io.IOException
public static void copyTree(java.io.File source,
java.io.File destinationDir)
throws java.io.IOException
java.io.IOException
public static void copyTree(java.io.File source,
java.io.File destinationDir,
FileActivityListener nosy)
throws java.io.IOException
java.io.IOException
public static void copyTreeContents(java.io.File source,
java.io.File destinationDir)
throws java.io.IOException
java.io.IOException
public static void copyTreeContents(java.io.File source,
java.io.File destinationDir,
FileActivityListener nosy)
throws java.io.IOException
java.io.IOException
public static void copyTreeNoOverwrite(java.io.File source,
java.io.File destination)
throws java.io.IOException
java.io.IOException
public static void removeTree(java.io.File victim)
throws java.io.IOException
java.io.IOException
public static void removeTree(java.io.File victim,
FileActivityListener nosy)
throws java.io.IOException
java.io.IOException
public static void removeTreeContents(java.io.File victim)
throws java.io.IOException
java.io.IOException
public static java.lang.String removeParentPath(java.lang.String parent,
java.lang.String victim)
throws java.io.IOException
java.io.IOException
public static int countFilesInTree(java.io.File dir)
throws java.io.IOException
java.io.IOException
public static long copy(java.io.File source,
java.io.File dest)
throws java.io.IOException
java.io.IOException
public static long copy(java.io.File source,
java.io.File dest,
FileActivityListener nosy)
throws java.io.IOException
java.io.IOException
public static long copy(java.lang.String source,
java.lang.String dest)
throws java.io.IOException
java.io.IOException
public static long fileCopy(java.io.File source,
java.io.File dest)
throws java.io.IOException
java.io.IOException
public static byte[] loadStream(java.io.InputStream source)
throws java.io.IOException
java.io.IOException
public static byte[] loadFile(java.io.File source)
throws java.io.IOException
java.io.IOException
public static long[] loadFileOfLongs(java.io.File source)
throws java.io.IOException
java.io.IOException
public static java.lang.String loadFileAsString(java.io.File file)
throws java.io.IOException
java.io.IOException
public static void saveFile(byte[] contents,
java.io.File source)
throws java.io.IOException
java.io.IOException
public static void saveFile(java.lang.String contents,
java.io.File source)
throws java.io.IOException
java.io.IOException
public static long checksum(java.io.File victim)
throws java.io.IOException
java.io.IOException
public static java.lang.String[] listFilesRemoveExtension(java.io.File dir,
java.lang.String extension)
public static java.lang.String removeExtension(java.lang.String filename)
public static java.lang.String removePathAndExtension(java.lang.String filename)
public static java.lang.String removeFileName(java.lang.String filename)
public static java.lang.String timestampFileName(java.lang.String filename)
public static java.io.File createTempFile(java.lang.String filename)
public static java.io.File reserveTempFile(java.io.File original)
throws java.io.IOException
java.io.IOException
public static java.io.File moveToTempFile(java.io.File original)
throws java.io.IOException
java.io.IOException
public static void move(java.io.File from,
java.io.File to)
throws java.io.IOException
java.io.IOExceptionpublic static java.io.File createTempFile(java.io.File file)
public static java.io.File createTempDir()
throws java.io.IOException
java.io.IOException
public static java.lang.String relativePath(java.io.File root,
java.io.File filet)
throws java.io.IOException
java.io.IOException
public static void deleteFileAndParentIfEmpty(java.io.File victim)
throws java.io.IOException
java.io.IOException
public static java.io.File canonicalize(java.io.File victim)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String makeValidFilename(java.lang.String source)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||