superwaba.ext.xplat.io
Class LineReader

java.lang.Object
  |
  +--superwaba.ext.xplat.io.LineReader

public class LineReader
extends java.lang.Object

Class that read lines ending with 0d0a (enter/linefeed) from a stream. Well, it skips all control-characters and assumes that the first one is the line breaker. This makes it suitable for either Windows or Linux end-of-line sequences.

Here's a sample:

 LineReader reader = new LineReader(new File("text.txt"));
 String line;
 while ((line = reader.readLine()) != null)
 {
    ... do whatever you want with the line.
 }
 

Since:
SuperWaba 5.12

Field Summary
protected  Stream f
           
 int maxTries
          The number of times it tries to read more data if none is available.
protected  int ofs
           
protected  ByteArrayStream readBuf
           
 
Constructor Summary
LineReader(Stream f)
          Constructs a new LineReader and sets maxTries accordingly to the type of class
 
Method Summary
 java.lang.String readLine()
          Returns the next line available on this stream or null if none.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

f

protected Stream f

readBuf

protected ByteArrayStream readBuf

ofs

protected int ofs

maxTries

public int maxTries
The number of times it tries to read more data if none is available. Defaults to 10 if the Stream is a Socket or a SerialPort, 0 otherwise.
Constructor Detail

LineReader

public LineReader(Stream f)
Constructs a new LineReader and sets maxTries accordingly to the type of class
Method Detail

readLine

public java.lang.String readLine()
Returns the next line available on this stream or null if none. Empty lines are skipped.