|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmckay.utilities.staticlibraries.FileMethods
public class FileMethods
A holder class for static methods relating to files.
Constructor Summary | |
---|---|
FileMethods()
|
Method Summary | |
---|---|
static void |
copyFile(java.lang.String original,
java.lang.String destination)
Copies the contents of one file to another. |
static boolean |
createEmptyDirectory(java.lang.String path)
Creates a directory at the given path. |
static boolean |
deleteDirectoryRecursively(java.io.File directory)
Deletes all files and sub-directories in the given directory. |
static java.io.File[] |
getAllFilesInDirectory(java.io.File directory,
boolean explore_subdirectories,
java.io.FileFilter filter,
java.util.Vector<java.io.File> results)
Returns all files meeting the requirements of the given filter in the given directory and, if requested, its subdirectories. |
static java.io.DataOutputStream |
getDataOutputStream(java.io.File file)
Prepares a DataOutputStream that can be used to write a file. |
static java.io.File |
getNewFileForWriting(java.lang.String path,
boolean can_erase)
Gets a new File object to write to based on the given path. |
static java.lang.String[] |
parseTextFileLines(java.io.File to_parse)
Parses the given text file. |
static boolean |
validateFile(java.io.File file,
boolean need_read,
boolean need_write)
Tests the given file to see if it is a valid file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileMethods()
Method Detail |
---|
public static java.io.File getNewFileForWriting(java.lang.String path, boolean can_erase)
path
- The path to which the file is to be saved.can_erase
- Whether or not the file should be automatically
overwritten if it already exists.
public static java.io.DataOutputStream getDataOutputStream(java.io.File file) throws java.io.FileNotFoundException
file
- The File that will be written to.
java.io.FileNotFoundException
- This exception is thrown if the
given file cannot be found.public static boolean validateFile(java.io.File file, boolean need_read, boolean need_write) throws java.lang.Exception
file
- The file to test.need_read
- If this is set to true, then an exception is
sent if the file cannot be read from.need_write
- If this is set to true, then an exception is
sent if the file cannot be written to.
java.lang.Exception
- An informative exception is thrown if there is
a problem with the file.public static java.io.File[] getAllFilesInDirectory(java.io.File directory, boolean explore_subdirectories, java.io.FileFilter filter, java.util.Vector<java.io.File> results)
directory
- The directory to explore.explore_subdirectories
- Whether or not the subdirectories of
directory should be explored.filter
- A filter controlling what files are
elligible to be returned. A value of
null means all files found will be
returned.results
- Used internally for recursive calls.
Pass null when calling this method
externally.
public static boolean createEmptyDirectory(java.lang.String path)
If a deletion fails, then the method stops attempting to delete and returns false.
path
- The path at which a directory is to be created.
public static boolean deleteDirectoryRecursively(java.io.File directory)
If a deletion fails, then the method stops attempting to delete and returns false.
directory
- The directory to delete.
public static void copyFile(java.lang.String original, java.lang.String destination) throws java.lang.Exception
original
- The name of the file to be copied.destination
- The name of the file to be copied to.
java.lang.Exception
- An exception is thrown if a problem occurs
during copying.public static java.lang.String[] parseTextFileLines(java.io.File to_parse) throws java.lang.Exception
to_parse
- The file to parse.
java.lang.Exception
- An informative description of any problem that
occurs during parsing.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |