Package org.apache.tools.ant.util
Class ReaderInputStream
java.lang.Object
java.io.InputStream
org.apache.tools.ant.util.ReaderInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
StringInputStream
Adapts a
Reader
as an InputStream
.
This is a stripped down version of org.apache.commons.io.input.ReaderInputStream
of Apache Commons IO 2.7.
-
Constructor Summary
ConstructorDescriptionReaderInputStream
(Reader reader) Construct aReaderInputStream
for the specifiedReader
.ReaderInputStream
(Reader reader, String encoding) Construct aReaderInputStream
for the specifiedReader
, with the specified encoding.ReaderInputStream
(Reader reader, Charset charset) Construct aReaderInputStream
for the specifiedReader
, with the specified encoding.ReaderInputStream
(Reader reader, CharsetEncoder encoder) Construct a newReaderInputStream
.ReaderInputStream
(Reader reader, CharsetEncoder encoder, int bufferSize) Construct a newReaderInputStream
. -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
ReaderInputStream
Construct a newReaderInputStream
.- Parameters:
reader
- the targetReader
encoder
- the charset encoder- Since:
- 1.10.9
-
ReaderInputStream
Construct a newReaderInputStream
.- Parameters:
reader
- the targetReader
encoder
- the charset encoderbufferSize
- the size of the input buffer in number of characters- Since:
- 1.10.9
-
ReaderInputStream
Construct aReaderInputStream
for the specifiedReader
.- Parameters:
reader
-Reader
. Must not benull
.
-
ReaderInputStream
-
ReaderInputStream
-
-
Method Details
-
read
Read the specified number of bytes into an array.- Overrides:
read
in classInputStream
- Parameters:
array
- the byte array to read intooff
- the offset to start reading bytes intolen
- the number of bytes to read- Returns:
- the number of bytes read or
-1
if the end of the stream has been reached - Throws:
IOException
- if an I/O error occurs
-
read
Read the specified number of bytes into an array.- Overrides:
read
in classInputStream
- Parameters:
b
- the byte array to read into- Returns:
- the number of bytes read or
-1
if the end of the stream has been reached - Throws:
IOException
- if an I/O error occurs
-
read
Read a single byte.- Specified by:
read
in classInputStream
- Returns:
- either the byte read or
-1
if the end of the stream has been reached - Throws:
IOException
- if an I/O error occurs
-
close
Close the stream. This method will cause the underlyingReader
to be closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- if an I/O error occurs
-