|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.foxsmart.ic.io.IoUtils
public class IoUtils
This class provides various I/O utilities via static methods.
| Field Summary | |
|---|---|
protected static org.apache.commons.logging.Log |
log
|
| Constructor Summary | |
|---|---|
IoUtils()
|
|
| Method Summary | |
|---|---|
static java.lang.Object |
clone(java.lang.Object object)
Clones the passed in object by serializing and deserializing all the serialized contents of the object. |
static void |
createDirectory(java.lang.String directoryName)
Creates a directory if one doesn't already exist for the specified directory name. |
static void |
createDirectory(java.lang.String filename,
boolean isFile)
Creates a directory if one doesn't already exist based on a filename. |
static void |
deleteFile(java.io.File file,
boolean recursiveDelete)
Removes a file, a directory, or recursive directories. |
static java.lang.String |
getFileContents(java.io.File file)
Reads and returns the contents of the specified file. |
static java.lang.String |
getFileContents(java.lang.String filename)
Reads and returns the contents of the specified file. |
static java.util.List<java.io.File> |
getFiles(java.lang.String filename)
Gets a list of files based on the passed in filename. |
static java.lang.String |
getFullPath(java.lang.String directoryName,
java.lang.String filename)
Returns the full path by combining the directory name and the filename. |
static void |
writeFile(java.io.File file,
java.lang.String fileContents)
Writes the file contents to the specified file. |
static boolean |
writeFile(java.lang.String directory,
java.lang.String filename,
java.lang.String fileContents,
boolean createDirectory,
boolean overwrite)
Writes the file contents to the specified directory and filename. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.commons.logging.Log log
| Constructor Detail |
|---|
public IoUtils()
| Method Detail |
|---|
public static void deleteFile(java.io.File file,
boolean recursiveDelete)
throws java.lang.Exception
file - The file or directory to deleterecursiveDelete - Flag to indicate whether the directory that was passed in should be recursively deleted.
This parameter is ignored if the passed in File is a normal file.
java.lang.Exception - if there was a problem deleting any file that should have been deleted. Note that if an
exception is thrown, several files may have already been deleted and will not be restored.
public static void createDirectory(java.lang.String directoryName)
throws java.io.IOException
directoryName - The name of the directory to create
java.io.IOException - if the directory could not be created.
public static void createDirectory(java.lang.String filename,
boolean isFile)
throws java.io.IOException
filename - The filename of the directory of file.isFile - If true, the filename specifies a file. If false, the filename specifies a directory.
java.io.IOException - if the directory could not be created.
public static java.util.List<java.io.File> getFiles(java.lang.String filename)
throws java.lang.Exception
filename - the filename.
java.lang.Exception - if there is a problem processing the filename.
public static java.lang.String getFileContents(java.lang.String filename)
throws java.io.IOException
filename - The file whose contents will be read.
java.io.IOException - if the file doesn't exist or it's contents could not be read.
public static java.lang.String getFileContents(java.io.File file)
throws java.io.IOException
file - The file whose contents will be read.
java.io.IOException - if the file doesn't exist or it's contents could not be read.
public static java.lang.Object clone(java.lang.Object object)
throws java.lang.Exception
object - The object to clone
java.lang.Exception - if the object could not be cloned.
public static java.lang.String getFullPath(java.lang.String directoryName,
java.lang.String filename)
directoryName - the directory name.filename - the filename.
public static boolean writeFile(java.lang.String directory,
java.lang.String filename,
java.lang.String fileContents,
boolean createDirectory,
boolean overwrite)
throws java.io.IOException
directory - the directory of the file to create.filename - the filename of the file to create.fileContents - the contents of the file to write.createDirectory - If true, the directory will be created. Otherwise, no directory will be created.overwrite - If true, the an existing file will be overwritten. Othewise, the file will not be written.
java.io.IOException - if any problems were encountered writing to the file.
public static void writeFile(java.io.File file,
java.lang.String fileContents)
throws java.io.IOException
file - the file that will contain the file contents.fileContents - the file contents to write to the file.
java.io.IOException - if any problems were encountered writing to the file.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||