Class FileUtil
java.lang.Object
|
+--FileUtil
- public class FileUtil
- extends java.lang.Object
This class contains utility routines for manipulating files.
Usage:
- The typical scenario for using this class is:
String s = FileUtil.getTextFileContents("/dir/filename.txt");
Assumptions:
Effects:
- None.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
- Since:
- 1.0.0
- Version:
- $Revision: 4 $
- Author:
- $Author: FStluka $
Inner Class Summary |
static class |
FileUtil.Tester
Each class contains a Tester inner class with a main() for easier
unit testing. |
Constructor Summary |
FileUtil()
Constructor. |
Method Summary |
static void |
appendToFile(java.lang.String strFilename,
java.lang.String strString)
Append the specified string to the specified file, opening and closing
the file to do so. |
static java.lang.String |
getTextFileContents(java.lang.String strFilename)
Returns the contents of the requested text file as a string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileUtil
public FileUtil()
- Constructor.
- Parameters:
None.
- - Throws:
Exceptions
- None.
getTextFileContents
public static java.lang.String getTextFileContents(java.lang.String strFilename)
throws java.io.FileNotFoundException,
java.io.IOException
- Returns the contents of the requested text file as a string.
- Parameters:
strFilename
- String name of the file to get.- Returns:
- Contents of the file as a string.
- Throws:
java.io.FileNotFoundException
- When the specified file is not found.java.io.IOException
- When an error occurs reading the file.
appendToFile
public static void appendToFile(java.lang.String strFilename,
java.lang.String strString)
throws java.io.IOException
- Append the specified string to the specified file, opening and closing
the file to do so.
- Parameters:
strFilename
- String name of the file to get.strString
- String to append to the file.- Returns:
- None.
- Throws:
java.io.IOException
- When an error occurs writing the file.