|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.iastate.utils.io.FileUtils
Provides some useful methods when working with files.
| Constructor Summary | |
private |
FileUtils()
Private constructor to avoid accidental instantiation. |
| Method Summary | |
static boolean |
appendFile(java.lang.String fullname,
java.lang.String text)
|
static void |
copy(java.io.File original,
java.io.File destination)
Copies the contents of a file to another. |
static void |
copy(java.lang.String filePath,
java.lang.String destinationPath)
Copies one file from its current path to another. |
static boolean |
copyIfPossible(java.io.File original,
java.io.File destination)
Copies the contents of a file to another. |
static boolean |
copyIfPossible(java.lang.String originalPath,
java.lang.String destinationPath)
Copies the contents of a file (referred by given path) to another. |
static java.lang.String |
findExtension(java.lang.String fullname)
|
static java.lang.String |
findName(java.lang.String fullname)
find the file name without path or extension |
static byte[] |
getBytesFromFile(java.io.File file)
|
static boolean |
isFileExists(java.lang.String fullname)
|
static void |
move(java.io.File originalFile,
java.io.File destinationFile)
Moves a file. |
static void |
move(java.lang.String filePath,
java.lang.String destinationPath)
Moves a file from one path to another, if possible. |
static boolean |
moveIfPossible(java.io.File originalFile,
java.io.File destinationFile)
Moves a file, if possible. |
static boolean |
moveIfPossible(java.lang.String filePath,
java.lang.String destinationPath)
Moves a file from one path to another, if possible. |
static java.lang.String |
readFile(java.io.File file)
Reads a file and returns its contents. |
static java.lang.String |
readFile(java.lang.String filePath)
Reads a file pointed by given path, and returns its contents. |
static java.lang.String |
readFileIfPossible(java.io.File file)
Reads a file and returns its contents, if possible. |
static java.lang.String |
readFileIfPossible(java.lang.String filePath)
Reads a file by its path and returns its contents, if possible. |
static void |
writeFile(java.io.File file,
java.lang.String contents)
Writes a file with given contents. |
static void |
writeFile(java.lang.String filePath,
java.lang.String contents)
Writes a file referred by given path, with given contents. |
static boolean |
writeFileIfPossible(java.io.File file,
java.lang.String contents)
Saves the contents to a file. |
static boolean |
writeFileIfPossible(java.lang.String filePath,
java.lang.String contents)
Saves the contents to a file. |
static java.io.File |
writeToTempFile(java.lang.String prefix,
java.lang.String suffix,
java.lang.String contens,
boolean deleteOnExit)
Save to temporary file |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
private FileUtils()
| Method Detail |
public static java.lang.String readFile(java.lang.String filePath)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
filePath - the path to the file to be read.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the operation is forbidden because of
security manager settings.
java.io.IOException - if some I/O exception occurs.
public static java.lang.String readFile(java.io.File file)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
file - the file to be read.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the operation is forbidden because of
security manager settings.
java.io.IOException - if some I/O exception occurs.public static java.lang.String readFileIfPossible(java.lang.String filePath)
filePath - the path to the file to be read.
public static java.lang.String readFileIfPossible(java.io.File file)
file - the file to be read.
public static boolean writeFileIfPossible(java.lang.String filePath,
java.lang.String contents)
filePath - the path of the file.contents - the text to save.
public static boolean writeFileIfPossible(java.io.File file,
java.lang.String contents)
file - the file to be overwritten.contents - the text to save.
public static void writeFile(java.lang.String filePath,
java.lang.String contents)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
filePath - the path of the file.contents - the text to write.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the security manager forbids this
operation.
java.io.IOException - if any other I/O error occurs.
public static void writeFile(java.io.File file,
java.lang.String contents)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
file - the file to write.contents - the text to write.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the security manager forbids this
operation.
java.io.IOException - if any other I/O error occurs.
public static void copy(java.lang.String filePath,
java.lang.String destinationPath)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
filePath - file's path.destinationPath - the new path of the file.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the security manager forbids this
operation.
java.io.IOException - if any other I/O error occurs.
public static void copy(java.io.File original,
java.io.File destination)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
original - the content to copy.destination - the file to be overwritten.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the security manager forbids this
operation.
java.io.IOException - if any other I/O error occurs.
public static boolean copyIfPossible(java.lang.String originalPath,
java.lang.String destinationPath)
originalPath - the path of the file to copy.destinationPath - the path of the file to be overwritten.
public static boolean copyIfPossible(java.io.File original,
java.io.File destination)
original - the content to copy.destination - the file to be overwritten.
public static void move(java.io.File originalFile,
java.io.File destinationFile)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
originalFile - the file to move.destinationFile - the new file.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the security manager forbids this
operation.
java.io.IOException - if any other I/O error occurs.
public static void move(java.lang.String filePath,
java.lang.String destinationPath)
throws java.io.FileNotFoundException,
java.lang.SecurityException,
java.io.IOException
filePath - the path of the file to move.destinationPath - the new file's path.
java.io.FileNotFoundException - if the file is not found.
java.lang.SecurityException - if the security manager forbids this
operation.
java.io.IOException - if any other I/O error occurs.
public static boolean moveIfPossible(java.io.File originalFile,
java.io.File destinationFile)
originalFile - the file to move.destinationFile - the new file.
public static boolean moveIfPossible(java.lang.String filePath,
java.lang.String destinationPath)
filePath - the path of the file to move.destinationPath - the new file's path.
public static java.lang.String findExtension(java.lang.String fullname)
public static java.lang.String findName(java.lang.String fullname)
fullname - String
public static boolean appendFile(java.lang.String fullname,
java.lang.String text)
fullname - Stringtext - String
public static boolean isFileExists(java.lang.String fullname)
public static byte[] getBytesFromFile(java.io.File file)
throws java.io.IOException
java.io.IOException
public static java.io.File writeToTempFile(java.lang.String prefix,
java.lang.String suffix,
java.lang.String contens,
boolean deleteOnExit)
prefix - String - could be nullsuffix - String - could be nullcontens - String - to writedeleteOnExit - boolean - if delete the file on exit
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||