multigraph.util
Class LineReader

java.lang.Object
  extended bymultigraph.util.LineReader

public class LineReader
extends java.lang.Object

LineReader is a wrapper class around java.io.Reader that provides for line by line reading of data. Usage is as follows:

    Reader rd = ...
    LineReader lr = new LineReader(rd);
    String line;
    while ( (line=lr.readLine()) != null ) {
       ...
    }
 
The readLine() method returns the next line (up to but not including the next '\n' character, or to EOF if there are no more such characters) from the Reader. Once EOF is reached on the Reader, readLine() returns null.

Note: readLine skips '\r' characters in the input stream; it neither counts them as part of an end-of-line marker, nor includes them in the string being returned. This is a hack to reasonably deal with both types of end-of-line conventions: ones that use a single '\n', and ones that use a '\r' followed by a '\n'.

Version:
$Id: LineReader.java,v 1.1.1.1 2004/11/30 22:30:41 mphillips Exp $
Author:
Mark Phillips

Constructor Summary
LineReader(java.io.Reader rd)
          Create a new LineReader instance using the given Reader object and having the default internal buffer size.
LineReader(java.io.Reader rd, int bufsize)
          Create a new LineReader instance using the given Reader object, and having an internal buffer size of bufsize.
 
Method Summary
 java.lang.String readLine()
          Return the next line of characters from the Reader, up to but not including the next '\n' or '\r', or EOF.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineReader

public LineReader(java.io.Reader rd,
                  int bufsize)
Create a new LineReader instance using the given Reader object, and having an internal buffer size of bufsize. We read from the Reader in chunks of this size.

Parameters:
rd - the Reader to read from
bufsize - length of internal buffer

LineReader

public LineReader(java.io.Reader rd)
Create a new LineReader instance using the given Reader object and having the default internal buffer size.

Parameters:
rd - the Reader that this LineReader should read from
Method Detail

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Return the next line of characters from the Reader, up to but not including the next '\n' or '\r', or EOF. If there are no more characters before EOF, returns null.

Throws:
java.io.IOException