com.ibatis.common.io
Class ReaderInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.ibatis.common.io.ReaderInputStream
All Implemented Interfaces:
Closeable

public class ReaderInputStream
extends InputStream

An InputStream backed by a Reader


Field Summary
protected  byte[] buffer
           
protected  ByteArrayOutputStream byteArrayOut
           
protected  char[] chars
           
protected  int index
           
protected  int length
           
protected  Reader reader
           
protected  Writer writer
           
 
Constructor Summary
ReaderInputStream(Reader reader)
          Constructor to supply a Reader
ReaderInputStream(Reader reader, String encoding)
          Constructor to supply a Reader and an encoding
 
Method Summary
 int available()
           
 void close()
           
protected  void fillBuffer()
           
 int read()
           
 int read(byte[] data, int off, int len)
           
 
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

reader

protected Reader reader

byteArrayOut

protected ByteArrayOutputStream byteArrayOut

writer

protected Writer writer

chars

protected char[] chars

buffer

protected byte[] buffer

index

protected int index

length

protected int length
Constructor Detail

ReaderInputStream

public ReaderInputStream(Reader reader)
Constructor to supply a Reader

Parameters:
reader - - the Reader used by the InputStream

ReaderInputStream

public ReaderInputStream(Reader reader,
                         String encoding)
                  throws UnsupportedEncodingException
Constructor to supply a Reader and an encoding

Parameters:
reader - - the Reader used by the InputStream
encoding - - the encoding to use for the InputStream
Throws:
UnsupportedEncodingException - if the encoding is not supported
Method Detail

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException
See Also:
InputStream.read()

fillBuffer

protected void fillBuffer()
                   throws IOException
Throws:
IOException

read

public int read(byte[] data,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException
See Also:
InputStream.read(byte[], int, int)

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException
See Also:
InputStream.available()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException
See Also:
InputStream.close()


Copyright © 2010. All Rights Reserved.