All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cs005.io.FileLineReader

java.lang.Object
   |
   +----cs005.io.FileLineReader

public class FileLineReader
extends Object
Package cs005.io;
Class FileLineReader,
Last modified: 8/11/97 5:15pm

This is the class that handles reading from files. To use this class,
just supply the path to the file you want to read to the constructor.
Then, call the read methods or the readLine method to get the
information from the file you are reading. You should not need to
subclass this class.

Constructor Index

 o FileLineReader(String)
Constructor: FileLineReader

This will create a new FileLineReader with the given path.

Method Index

 o getLineNumber()
Method: getLineNumber

This returns the number of the current line that the reader is reading from.

 o read()
Method read

This method returns a single character of information read from the file.

 o read(char[], int, int)
Method read

This is another version of the read method.

 o readLine()
Method: readLine

This returns the actual line of text that the reader is currently on.

 o setLineNumber(int)
Method: setLineNumber

This method sets the current line number to the supplied parameter.

Constructors

 o FileLineReader
 public FileLineReader(String path)
Constructor: FileLineReader

This will create a new FileLineReader with the given path. If the file is not found, an InvalidFileException will be thrown.

Parameters:
path - the path to the file you want to read.

Methods

 o getLineNumber
 public int getLineNumber()
Method: getLineNumber

This returns the number of the current line that the reader is reading from.

Returns:
int the current line number
 o readLine
 public String readLine() throws InvalidFileException
Method: readLine

This returns the actual line of text that the reader is currently on. Once you call this method, the reader moves on to the next line of text, so it will never return the same line twice.

Returns:
String the line of text
 o setLineNumber
 public void setLineNumber(int lineNumber)
Method: setLineNumber

This method sets the current line number to the supplied parameter.

Parameters:
lineNumber - the new line number
 o read
 public int read() throws InvalidFileException
Method read

This method returns a single character of information read from the file. Like readLine, once you call this method, the reader moves on to the next line. This method is usually used inside of while loops for ease of separating into tokens manually.

Returns:
int the current character of the file
 o read
 public int read(char cbuffer[],
                 int offset,
                 int length) throws InvalidFileException
Method read

This is another version of the read method. This will read a section of the file from the supplied offset for the supplied length. The text is put into the character array parameter.

Parameters:
cbuffer - the buffer to put the text into
offset - where to start reading from
length - how many characters to read.

All Packages  Class Hierarchy  This Package  Previous  Next  Index