public class ReaderInputStream
extends java.io.InputStream
Reader
as an InputStream
.
This is a stripped down version of org.apache.commons.io.input.ReaderInputStream
of Apache Commons IO 2.7.
Constructor and Description |
---|
ReaderInputStream(java.io.Reader reader)
Construct a
ReaderInputStream
for the specified Reader . |
ReaderInputStream(java.io.Reader reader,
java.nio.charset.Charset charset)
Construct a
ReaderInputStream
for the specified Reader ,
with the specified encoding. |
ReaderInputStream(java.io.Reader reader,
java.nio.charset.CharsetEncoder encoder)
Construct a new
ReaderInputStream . |
ReaderInputStream(java.io.Reader reader,
java.nio.charset.CharsetEncoder encoder,
int bufferSize)
Construct a new
ReaderInputStream . |
ReaderInputStream(java.io.Reader reader,
java.lang.String encoding)
Construct a
ReaderInputStream
for the specified Reader ,
with the specified encoding. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the stream.
|
int |
read()
Read a single byte.
|
int |
read(byte[] b)
Read the specified number of bytes into an array.
|
int |
read(byte[] array,
int off,
int len)
Read the specified number of bytes into an array.
|
public ReaderInputStream(java.io.Reader reader, java.nio.charset.CharsetEncoder encoder)
ReaderInputStream
.reader
- the target Reader
encoder
- the charset encoderpublic ReaderInputStream(java.io.Reader reader, java.nio.charset.CharsetEncoder encoder, int bufferSize)
ReaderInputStream
.reader
- the target Reader
encoder
- the charset encoderbufferSize
- the size of the input buffer in number of characterspublic ReaderInputStream(java.io.Reader reader)
ReaderInputStream
for the specified Reader
.reader
- Reader
. Must not be null
.public ReaderInputStream(java.io.Reader reader, java.lang.String encoding)
ReaderInputStream
for the specified Reader
,
with the specified encoding.reader
- non-null Reader
.encoding
- non-null String
encoding.public ReaderInputStream(java.io.Reader reader, java.nio.charset.Charset charset)
ReaderInputStream
for the specified Reader
,
with the specified encoding.reader
- non-null Reader
.charset
- non-null Charset
charset.public int read(byte[] array, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
array
- the byte array to read intooff
- the offset to start reading bytes intolen
- the number of bytes to read-1
if the end of the stream has been reachedjava.io.IOException
- if an I/O error occurspublic int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
b
- the byte array to read into-1
if the end of the stream has been reachedjava.io.IOException
- if an I/O error occurspublic int read() throws java.io.IOException
read
in class java.io.InputStream
-1
if the end of the stream
has been reachedjava.io.IOException
- if an I/O error occurspublic void close() throws java.io.IOException
Reader
to be closed.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
- if an I/O error occurs