cds.util
Class ReadFile

java.lang.Object
  extended bycds.util.ReadFile

public class ReadFile
extends java.lang.Object

Class for reading ascii lines in a file

Version:
1.0 Feb 2002
2.0 Jun 2002 Accepts InputStream, and URLs as file reference
Author:
Marc Wenger/CDS

Field Summary
(package private)  int ctline
           
(package private)  java.io.BufferedReader rdr
           
 
Constructor Summary
ReadFile()
          enpty constructor
ReadFile(java.lang.String filename)
          Constructor with a filename.
 
Method Summary
 void close()
          Closes the file
 java.lang.String getLine()
          Reads a line.
 int lineno()
          Returns the number of the current line
 void open(java.lang.String filename)
          opend a ReadFile object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rdr

java.io.BufferedReader rdr

ctline

int ctline
Constructor Detail

ReadFile

public ReadFile()
enpty constructor


ReadFile

public ReadFile(java.lang.String filename)
         throws java.io.IOException,
                java.io.FileNotFoundException,
                java.net.MalformedURLException
Constructor with a filename. This constructor opens also the file.

Parameters:
filename - nale of the file to open. If the filename is null or an empty string the the standard input is used.
Method Detail

open

public void open(java.lang.String filename)
          throws java.io.IOException,
                 java.io.FileNotFoundException,
                 java.net.MalformedURLException
opend a ReadFile object.

Parameters:
filename - name of the file to open. If the filename is null or an empty string the the standard input is used.
Throws:
java.io.IOException
java.io.FileNotFoundException
java.net.MalformedURLException

getLine

public java.lang.String getLine()
                         throws java.io.IOException
Reads a line. The terminating character ("\n" for instance) is NOT included.

Returns:
The line read, or null at the end of the file.
Throws:
java.io.IOException

lineno

public int lineno()
Returns the number of the current line

Returns:
line number

close

public void close()
           throws java.io.IOException
Closes the file

Throws:
java.io.IOException