ewe.io
Class Reader

java.lang.Object
  extended byewe.io.Reader
Direct Known Subclasses:
BufferedReader, CharArrayReader, StringReader, TextReader

public abstract class Reader
extends Object

Abstract class for reading character streams. The only methods that a subclass must implement are read(char[], int, int) and close().


Field Summary
protected  Lock lock
          The object used to synchronize operations on this stream.
 
Constructor Summary
protected Reader()
           
protected Reader(Lock lock)
          Create a new character-stream reader whose critical sections will synchronize on the given object.
 
Method Summary
abstract  void close()
          Close the stream.
 Lock getLock()
          Get the Lock object used to synchronize IO operations on this Reader.
 void mark(int readLimit)
           
 boolean markSupported()
           
 int read()
          Read a single character.
 int read(char[] cbuf)
          Read characters into an array.
abstract  int read(char[] cbuf, int off, int len)
          Read characters into a portion of an array.
 boolean ready()
          Tell whether this stream is ready to be read.
 void reset()
           
 long skip(long toSkip)
          Skip over a certain number of characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

lock

protected Lock lock
The object used to synchronize operations on this stream.

Constructor Detail

Reader

protected Reader()

Reader

protected Reader(Lock lock)
Create a new character-stream reader whose critical sections will synchronize on the given object.

Method Detail

getLock

public Lock getLock()
Get the Lock object used to synchronize IO operations on this Reader.


read

public int read()
         throws IOException
Read a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Returns:
The character read, as an integer in the range 0 to 0xffff, or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs

read

public int read(char[] cbuf)
         throws IOException
Read characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

Parameters:
cbuf - Destination buffer
Returns:
The number of bytes read, or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs

read

public abstract int read(char[] cbuf,
                         int off,
                         int len)
                  throws IOException
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

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

skip

public long skip(long toSkip)
          throws IOException
Skip over a certain number of characters.

Parameters:
toSkip - the number of characters to skip over.
Returns:
the actual number of characters skipped - which may be less than toSkip.
Throws:
IOException - if an I/O error occurs while skipping.

ready

public boolean ready()
              throws IOException
Tell whether this stream is ready to be read.

Returns:
True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
Throws:
IOException - If an I/O error occurs

markSupported

public boolean markSupported()

mark

public void mark(int readLimit)
          throws IOException
Throws:
IOException

reset

public void reset()
           throws IOException
Throws:
IOException

close

public abstract void close()
                    throws IOException
Close the stream.

Throws:
IOException - If an I/O error occurs