org.paneris.util
Class CRLFFtellReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by org.paneris.util.CRLFFtellReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class CRLFFtellReader
extends java.io.FilterReader


Field Summary
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
CRLFFtellReader(java.io.BufferedReader in)
          Create a new CRLFFtellReader.
CRLFFtellReader(java.io.File f)
          Create a new CRLFFtellReader.
 
Method Summary
 long getFtell()
          Get the current position.
 void mark(int readAheadLimit)
          Mark the present position in the stream.
 int read()
          Read a single character.
 int read(char[] cbuf, int off, int len)
          Read characters into a portion of an array.
 java.lang.String readLine()
          Read a line from the stream.
 void reset()
          Reset the stream to the most recent mark.
 long skip(long n)
          Skip characters.
 
Methods inherited from class java.io.FilterReader
close, markSupported, ready
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRLFFtellReader

public CRLFFtellReader(java.io.BufferedReader in)
Create a new CRLFFtellReader.


CRLFFtellReader

public CRLFFtellReader(java.io.File f)
                throws java.io.FileNotFoundException
Create a new CRLFFtellReader.

Throws:
java.io.FileNotFoundException
Method Detail

getFtell

public long getFtell()
Get the current position.


read

public int read()
         throws java.io.IOException
Read a single character.

Overrides:
read in class java.io.FilterReader
Returns:
The character read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Read characters into a portion of an array.

Overrides:
read in class java.io.FilterReader
Parameters:
cbuf - Destination buffer
off - Offset at which to start storing characters
len - Maximum number of characters to read
Returns:
The number of bytes read, or -1 if the end of the stream has already been reached
Throws:
java.io.IOException - If an I/O error occurs

skip

public long skip(long n)
          throws java.io.IOException
Skip characters.

Overrides:
skip in class java.io.FilterReader
Parameters:
n - The number of characters to skip
Returns:
The number of characters actually skipped
Throws:
java.io.IOException - If an I/O error occurs

mark

public void mark(int readAheadLimit)
          throws java.io.IOException
Mark the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point, and will also reset the line number appropriately.

Overrides:
mark in class java.io.FilterReader
Parameters:
readAheadLimit - Limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail.
Throws:
java.io.IOException - If an I/O error occurs

reset

public void reset()
           throws java.io.IOException
Reset the stream to the most recent mark.

Overrides:
reset in class java.io.FilterReader
Throws:
java.io.IOException - If the stream has not been marked, or if the mark has been invalidated

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Read a line from the stream. FIXME if the line is not terminated with CR+LF, the getFtell() value will henceforth be off by one. Really, an efficient and 100% correct CRLFFtellReader would have to be based on BufferedReader.

Throws:
java.io.IOException - If an I/O error occurs


Copyright © 2000-2008 PanEris. All Rights Reserved.