text
Class TextFileIO

java.lang.Object
  extended by text.TextFileIO
All Implemented Interfaces:
TextConstants

public class TextFileIO
extends java.lang.Object
implements TextConstants

TextFileIO Class receives the file name and either saves the file or reads the file.


Field Summary
 
Fields inherited from interface text.TextConstants
COMMA, CREATED_BY_ZYX, DELIM, DOUBLE_QUOTE, ELEMENT_DOCUMENT, ELEMENT_ITEM, EMPTY, FALSE, FORWARD_SLASH, FOUR_SPACES, ID_EQUALS, JAVA_LANG_STRING, LEFT_ANGLE, LEFT_BRACE, LEFT_BRACKET, MENU_ONE, MENU_TWO, NEW_LINE, ONE, RIGHT_ANGLE, RIGHT_BRACE, RIGHT_BRACKET, SEMICOLON, SINGLE_QUOTE, SPACE, TRUE, TWO, XML_VERSION, ZERO
 
Constructor Summary
TextFileIO()
           
 
Method Summary
static java.lang.String getContent(java.lang.String filename)
          This method opens a file and returns the file's content.
static java.lang.String getDELIM()
          Gets one empty space.
private static java.lang.String readText(java.io.File textFile)
          This method reads each line of the file assigns it to a temporary variable and then inserts an end line statement.
static boolean saveContent(java.lang.String filename, java.lang.String content)
          This method calls saveText method and returns boolean variable representing success or failure of saving.
static boolean saveText(java.lang.String filename, java.lang.String content)
          This method attempts to write a file to the disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextFileIO

public TextFileIO()
Method Detail

readText

private static java.lang.String readText(java.io.File textFile)
                                  throws java.io.IOException
This method reads each line of the file assigns it to a temporary variable and then inserts an end line statement.

Parameters:
textFile - is the file object to be read.
Returns:
content - a string representation of what is in the file.
Throws:
java.io.IOException - - this exception is caught at the Business Object layer to signal the I/O problem occurred.

getDELIM

public static java.lang.String getDELIM()
Gets one empty space.

Returns:
string of one empty space.

getContent

public static java.lang.String getContent(java.lang.String filename)
                                   throws java.io.FileNotFoundException,
                                          java.io.IOException
This method opens a file and returns the file's content.

Parameters:
filename - is the name of the file to be opened.
Returns:
content - a string representation of what is in the file.
Throws:
java.io.FileNotFoundException - - this exception is caught at the Business Object layer to signal the file does not exist.
java.io.IOException - - this exception is caught at the Business Object layer to signal the I/O problem occurred.

saveContent

public static boolean saveContent(java.lang.String filename,
                                  java.lang.String content)
                           throws java.io.FileNotFoundException,
                                  java.io.IOException
This method calls saveText method and returns boolean variable representing success or failure of saving.

Parameters:
filename - - the name of the file to be saved as.
content - - the string representation of the data to be saved.
Returns:
saved - a boolean variable representing success or failure.
Throws:
java.io.FileNotFoundException - - this exception is caught at the Business Object layer to signal the file does not exist.
java.io.IOException - - this exception is caught at the Business Object layer to signal the I/O problem occurred.

saveText

public static boolean saveText(java.lang.String filename,
                               java.lang.String content)
                        throws java.io.IOException
This method attempts to write a file to the disk.

Parameters:
filename - - the name of the file to be saved as.
content - - the string representation of the data to be saved.
Returns:
a boolean variable representing success of saving.
Throws:
java.io.IOException - - this exception is caught at the Business Object layer to signal the I/O problem occurred.