de.web.databasesupport.tools.iotools
Class ASCIIFile

java.lang.Object
  |
  +--de.web.databasesupport.tools.iotools.ASCIIFile

public class ASCIIFile
extends java.lang.Object

handles ASCII-files


Constructor Summary
ASCIIFile()
           
 
Method Summary
static boolean append(java.io.File dest, java.lang.String text)
          Appends a text at a spezified file.
static int countLines(java.io.File source)
          Counts the available lines of the given file.
static boolean insert(java.io.File dest, java.lang.String text, int linenumber)
          Inserts a text at the given linenumber of the spezified file.
static java.lang.String read(java.io.File source)
          Reads a text from the spezified File and returns it as one big String.
static java.lang.String[] readAsArray(java.io.File source)
          Reads a text from the spezified File and returns it as a String-array. each line is represented as one field in the array.
static java.util.Vector readAsVector(java.io.File source)
          Reads a text from the spezified File and returns it as a Vector of Strings. each line is represented through one String-object in the Vector.
static boolean write(java.io.File dest, java.lang.String text, boolean overwrite)
          Writes a text to the spezified File, if allowed.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASCIIFile

public ASCIIFile()
Method Detail

write

public static boolean write(java.io.File dest,
                            java.lang.String text,
                            boolean overwrite)
                     throws java.io.IOException
Writes a text to the spezified File, if allowed.
Parameters:
dest - Destination-file to write the text in.
text - Text to put in the file.
overwrite - Flag if allowed to overwrite an existing file (true if alowed, false otherwise).
Returns:
true if writing was succesfull, false if file aready exists and it is not allowed to overwrite it.

read

public static java.lang.String read(java.io.File source)
                             throws java.io.IOException
Reads a text from the spezified File and returns it as one big String.
Parameters:
source - Source-file to to read from.
Returns:
The text as one big String.

readAsVector

public static java.util.Vector readAsVector(java.io.File source)
                                     throws java.io.IOException
Reads a text from the spezified File and returns it as a Vector of Strings. each line is represented through one String-object in the Vector.
Parameters:
source - Source-file to to read from.
Returns:
The Vector of Strings, where each String-object represents a Line.

readAsArray

public static java.lang.String[] readAsArray(java.io.File source)
                                      throws java.io.IOException
Reads a text from the spezified File and returns it as a String-array. each line is represented as one field in the array.
Parameters:
source - Source-file to to read from.
Returns:
The Array of Strings, where each String-object represents a Line.

append

public static boolean append(java.io.File dest,
                             java.lang.String text)
Appends a text at a spezified file.
Parameters:
dest - Destination-file to to append the text at.
text - The text to append.
Returns:
true if appending was successfull, or false if something went wrong with reading or writing.

insert

public static boolean insert(java.io.File dest,
                             java.lang.String text,
                             int linenumber)
                      throws java.lang.IndexOutOfBoundsException
Inserts a text at the given linenumber of the spezified file.
Parameters:
dest - Destiantion-file where to insert the text.
text - The text to insert.
linenumber - The linenumber where to insert the text.
Returns:
true if inserting was successfull, false if something went wrong with reading or writing.

countLines

public static int countLines(java.io.File source)
                      throws java.io.IOException
Counts the available lines of the given file.
Parameters:
source - The Source-file to count the lines of.
Returns:
The number of lines in the spezified file