|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--edu.neu.ccs.util.FileUtilities
Provides utility methods that encapsulate file input and output operations.
| Constructor Summary | |
FileUtilities()
|
|
| Method Summary | |
static void |
copyFile(File source,
File destination,
boolean overwrite)
Copies the source file to the destination file. |
static void |
copyFile(String source,
String destination,
boolean overwrite)
Copies the file at the source path to the destination path. |
static void |
createDirectory(File dir)
Creates the given directory. |
static void |
createDirectory(String dir)
Creates a directory with the given path. |
static void |
deleteFile(File f)
Deletes the given file. |
static void |
deleteFile(String path)
Deletes the file at the given path. |
static StringBuffer |
getFileContents(File f)
Returns a StringBuffer
containing the contents of the given file. |
static String[] |
readDirectory(File f)
Returns an array of Strings
containing the names of the files
in the given directory. |
static String[] |
readDirectory(String path)
Returns an array of Strings
containing the names of the files
in the directory at the given path. |
static String |
readFile(File f)
Returns a String
containing the contents of the given file. |
static String |
readFile(String path)
Returns a String
containing the contents of the file
at the given path. |
static void |
renameFile(File source,
File destination)
Sets the name of the given file to the provided name. |
static void |
renameFile(String source,
String destination)
Renames the file at the given path to the given new path. |
static void |
writeFile(File f,
String data,
boolean overwrite)
Writes the given data to the given file. |
static void |
writeFile(String destination,
String data,
boolean overwrite)
Writes the given data to a file at the given path. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FileUtilities()
| Method Detail |
public static void copyFile(String source,
String destination,
boolean overwrite)
throws FileExistsException,
IOException
source - the path of the source file to copydestination - the path to copy the file tooverwrite - whether or not to automatically overwrite
existing file contents
FileExistsException - if the file exists
and is not to be automatically overwritten
IOException - if there is an error
reading the source file or writing the destination filecopyFile(File, File, boolean)
public static void copyFile(File source,
File destination,
boolean overwrite)
throws FileExistsException,
IOException
source - a source file to be copieddestination - the desination file to be writtenoverwrite - whether or not to automatically overwrite
existing file contents
FileExistsException - if the file exists
and is not to be automatically overwritten
IOException - if there is an error
reading the source file or writing the destination filecopyFile(String, String, boolean)
public static void createDirectory(File dir)
throws FileExistsException,
IOException
dir - the directory to be created
FileExistsException - if the file or directory
already exists
IOException - if there is an error
creating the directorycreateDirectory(String)
public static void createDirectory(String dir)
throws FileExistsException,
IOException
dir - the full path of the new directory
FileExistsException - if the file or directory
already exists
IOException - if there is an error
creating the directorycreateDirectory(File)
public static void deleteFile(File f)
throws FileNotFoundException,
IOException
f - the file to be deleted
FileNotFoundException - if the file
does not exist
IOException - if there was an error
deleting the filedeleteFile(String)
public static void deleteFile(String path)
throws FileNotFoundException,
IOException
path - the path of the file to be deleted
FileNotFoundException - if the file
does not exist
IOException - if there was an error
deleting the filedeleteFile(File)
public static String[] readDirectory(File f)
throws FileNotFoundException,
IOException
Strings
containing the names of the files
in the given directory.
f - the directory to be read
FileNotFoundException - if the directory
does not exist
IOException - if there was an error
reading the directoryreadDirectory(String)
public static String[] readDirectory(String path)
throws FileNotFoundException,
IOException
Strings
containing the names of the files
in the directory at the given path.
path - the full path of the directory
FileNotFoundException - if the directory
does not exist
IOException - if there was an error
reading the directoryreadDirectory(File)
public static StringBuffer getFileContents(File f)
throws FileNotFoundException,
IOException
StringBuffer
containing the contents of the given file.
f - the file to be read
FileNotFoundException - if the file
does not exist
IOException - if there was an error
reading the filereadFile(File),
readFile(String)
public static String readFile(File f)
throws FileNotFoundException,
IOException
String
containing the contents of the given file.
f - the file to be read
FileNotFoundException - if the file
does not exist
IOException - if there was an error
reading the filereadFile(String)
public static String readFile(String path)
throws FileNotFoundException,
IOException
String
containing the contents of the file
at the given path.
path - the path of the file to be read
FileNotFoundException - if the file
does not exist
IOException - if there was an error
reading the filereadFile(File)
public static void renameFile(File source,
File destination)
throws FileNotFoundException,
FileExistsException,
IOException
source - the file to be renameddestination - the new name for the file
FileNotFoundException - if the source file
is not found
FileExistsException - if the destination file
already exists and will be overwritten
IOException - if there is an error
renaming the filerenameFile(String, String)
public static void renameFile(String source,
String destination)
throws FileNotFoundException,
FileExistsException,
IOException
source - the full path of the file
to be renameddestination - the full path of the new name
for the file
FileNotFoundException - if a file at
the source path does not exist
FileExistsException - if a file exists
at the destination path and will be overwritten
IOException - if there is an error
renaming the filerenameFile(File, File)
public static void writeFile(File f,
String data,
boolean overwrite)
throws FileExistsException,
IOException
f - the file to be writtendata - the data to write to the fileoverwrite - whether or not to automatically
overwrite existing file contents
FileExistsException - if the file exists
and is not to be automatically overwritten
IOException - if there is an error
writing the filewriteFile(String, String, boolean)
public static void writeFile(String destination,
String data,
boolean overwrite)
throws FileExistsException,
IOException
destination - the full path of the file
to be writtendata - the data to write to the fileoverwrite - whether or not to automatically
overwrite existing file contents
FileExistsException - if the file exists
and is not to be automatically overwritten
IOException - if there is an error
writing the filewriteFile(File, String, boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||