public class ReaderInputStream extends InputStream
Reader
as an InputStream
.
Adapted from StringInputStream
.Constructor and Description |
---|
ReaderInputStream(Reader reader)
Construct a
ReaderInputStream
for the specified Reader . |
ReaderInputStream(Reader reader,
String encoding)
Construct a
ReaderInputStream
for the specified Reader ,
with the specified encoding. |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close()
Closes the Stringreader.
|
void |
mark(int limit)
Marks the read limit of the StringReader.
|
boolean |
markSupported() |
int |
read()
Reads from the
Reader , returning the same value. |
int |
read(byte[] b,
int off,
int len)
Reads from the
Reader into a byte array |
void |
reset()
Resets the StringReader.
|
read, skip
public ReaderInputStream(Reader reader)
ReaderInputStream
for the specified Reader
.reader
- Reader
. Must not be null
.public int read() throws IOException
Reader
, returning the same value.read
in class InputStream
Reader
.IOException
- if the original Reader
fails to be readpublic int read(byte[] b, int off, int len) throws IOException
Reader
into a byte arrayread
in class InputStream
b
- the byte array to read intooff
- the offset in the byte arraylen
- the length in the byte array to fillIOException
- if an error occurspublic void mark(int limit)
mark
in class InputStream
limit
- the maximum limit of bytes that can be read before the
mark position becomes invalidpublic int available() throws IOException
available
in class InputStream
IOException
- if an error occurspublic boolean markSupported()
markSupported
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
- if the StringReader fails to be resetpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- if the original StringReader fails to be closed