org.sourcejammer.util
Class BufferedLineReader

java.lang.Object
  |
  +--org.sourcejammer.util.BufferedLineReader

public class BufferedLineReader
extends java.lang.Object

Title: $FileName: BufferedLineReader.java$

Version:
$VerNum: 5$
Author:
$AuthorName: Rob MacGrogan$

$Description: Reads char files one line at a time without EOF EOL bug.$
$KeyWordsOff: $

This class iterates through the characters in a Reader object one line at at time. It might seem like this is the same as the function of java.io.BufferedReader, and in fact it is. But BufferedReader has a bug that causes it to drop the last line in a text file if that file contains only an EOL marker and nothing else. This class avoids this bug.

Field Summary
private  boolean endOfStream
           
private  java.lang.String fileEOL
           
private  boolean fileEOLSet
           
private  boolean firstLine
           
private  char lastEOL
           
private  java.io.Reader reader
           
private static java.lang.String WIN_EOL
           
 
Constructor Summary
BufferedLineReader(java.io.Reader reader)
           
 
Method Summary
 java.io.Reader getUnderlyingReader()
           
private  boolean isEOL(char ch)
          Returns true if the character is an EOL.
 boolean isExhausted()
           
static void main(java.lang.String[] args)
           
private  boolean needsNewLineAtEOF(java.lang.String line)
           
 java.lang.String readLine()
           
private  void setFileEOL(char ch)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reader

private java.io.Reader reader

lastEOL

private char lastEOL

endOfStream

private boolean endOfStream

firstLine

private boolean firstLine

WIN_EOL

private static final java.lang.String WIN_EOL

fileEOLSet

private boolean fileEOLSet

fileEOL

private java.lang.String fileEOL
Constructor Detail

BufferedLineReader

public BufferedLineReader(java.io.Reader reader)
Method Detail

isExhausted

public boolean isExhausted()

readLine

public java.lang.String readLine()
                          throws java.io.IOException
java.io.IOException

needsNewLineAtEOF

private boolean needsNewLineAtEOF(java.lang.String line)

setFileEOL

private void setFileEOL(char ch)

getUnderlyingReader

public java.io.Reader getUnderlyingReader()

isEOL

private boolean isEOL(char ch)
Returns true if the character is an EOL.


main

public static void main(java.lang.String[] args)


Copyright 2003 Soucejammer project.