org.wegra.io
Class ReaderInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.wegra.io.ReaderInputStream

public class ReaderInputStream
extends java.io.InputStream


Field Summary
protected  java.io.ByteArrayOutputStream fByteArrayOutputStream
           
protected  byte[] fByteBuffer
           
protected  char[] fCharBuffer
           
protected  int fIndex
           
protected  int fLength
           
protected  java.io.Reader fReader
          Internal Reader (data source)
protected  java.io.Writer fWriter
           
 
Constructor Summary
ReaderInputStream(java.io.Reader reader)
          Created instance will use runtime platform's default encoding method.
ReaderInputStream(java.io.Reader reader, java.lang.String encoding)
          Create one instance with specified encoding method.
 
Method Summary
 int available()
          Returns available length of bytes in stream (WARNING: See the return value's description).
 void close()
          Closes stream.
protected  void fillBuffer()
          Fills buffer from internal reader object (fReader).
 int read()
          Reads 1 byte and returns.
 int read(byte[] data, int offset, int length)
          Reads bytes of length and fills it to given data at specified offset.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fReader

protected java.io.Reader fReader
Internal Reader (data source)


fByteArrayOutputStream

protected java.io.ByteArrayOutputStream fByteArrayOutputStream

fWriter

protected java.io.Writer fWriter

fCharBuffer

protected char[] fCharBuffer

fByteBuffer

protected byte[] fByteBuffer

fIndex

protected int fIndex

fLength

protected int fLength
Constructor Detail

ReaderInputStream

public ReaderInputStream(java.io.Reader reader)
Created instance will use runtime platform's default encoding method.


ReaderInputStream

public ReaderInputStream(java.io.Reader reader,
                         java.lang.String encoding)
                  throws java.io.UnsupportedEncodingException
Create one instance with specified encoding method.

Method Detail

available

public int available()
              throws java.io.IOException
Returns available length of bytes in stream (WARNING: See the return value's description).

Returns:
Available length of buffer or 1 if data source has more data or 0 if not .
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes stream.

Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Reads 1 byte and returns.

Returns:
Read byte or -1 if stream reachs End of Stream.
Throws:
java.io.IOException

read

public int read(byte[] data,
                int offset,
                int length)
         throws java.io.IOException
Reads bytes of length and fills it to given data at specified offset.

Parameters:
data - Buffer to fill read bytes
offset - Offset of data to fill first
length - Length to read
Returns:
Length of successfully read bytes.
Throws:
java.io.IOException

fillBuffer

protected void fillBuffer()
                   throws java.io.IOException
Fills buffer from internal reader object (fReader).

Throws:
java.io.IOException