org.yajul.io
Class AbstractByteFilterReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by org.yajul.io.AbstractByteFilterReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public abstract class AbstractByteFilterReader
extends java.io.FilterReader

Implements the array based read method to simplify writing 'byte at a time' FilterReader classes. Sub-classes need only implement the read() method.
User: josh Date: Nov 27, 2002 Time: 8:38:44 AM

Author:
josh

Field Summary
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
AbstractByteFilterReader(java.io.Reader in)
          Creates a new AbstractByteFilterReader.
 
Method Summary
abstract  int read()
          Reads the next byte of data from this input stream.
 int read(char[] b, int off, int len)
          Reads up to len bytes of data from this input stream into an array of bytes.
protected  int readByte()
          Reads the next byte of data from this input stream.
 
Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, reset, skip
 
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

AbstractByteFilterReader

public AbstractByteFilterReader(java.io.Reader in)
Creates a new AbstractByteFilterReader.

Parameters:
in - The underlying input stream being filtered.
Method Detail

readByte

protected final int readByte()
                      throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterReader.in

read

public abstract int read()
                  throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Overrides:
read in class java.io.FilterReader
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterReader.in

read

public final int read(char[] b,
                      int off,
                      int len)
               throws java.io.IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

This method simply performs in.read(b, off, len) and returns the result.

Overrides:
read in class java.io.FilterReader
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterReader.in


Copyright © 2008. All Rights Reserved.