InputStream implementation that compiles for JDK 7 but can support the methods added in JDK 8
by reflection.
| Modifier and Type | Field and Description |
|---|---|
| private InputStream | |
| private static Method | |
| private static Method | |
| private static Method | |
| private static Method | |
| private static Method |
| Access | Constructor and Description |
|---|---|
| public | ProxyingInputStream(final InputStream
the inputStream)InputStream to wrap.A proxying |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. |
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| public synchronized void | mark(final int
the maximum limit of bytes that can be read before
the mark position becomes invalid. readlimit)Overrides java. Marks the current position in this input stream. |
| public boolean | markSupported()
Overrides java. Tests if this input stream supports the |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| public int | read(final byte[]
the buffer into which the data is read. b)Overrides java. Reads some number of bytes from the input stream and stores them into
the buffer array |
| public int | read(final byte[]
the buffer into which the data is read. b, final int the start offset in array off, final int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. Reads up to |
| public byte[] | readAllBytes()
Overrides java. Reads all remaining bytes from the input stream. |
| public byte[] | readNBytes(final int
the maximum number of bytes to read len)Overrides java. Reads up to a specified number of bytes from the input stream. |
| public int | readNBytes(final byte[]
the byte array into which the data is read b, final int the start offset in off, final int b at which the data is writtenthe maximum number of bytes to read len)Overrides java. Reads the requested number of bytes from the input stream into the given byte array. |
| public synchronized void | reset()
Overrides java. Repositions this stream to the position at the time the
|
| public long | skip(final long
the number of bytes to be skipped. n)Overrides java. Skips over and discards |
| public void | skipNBytes(final long
the number of bytes to be skipped. n)Overrides java. Skips over and discards exactly |
| public String | |
| public long | transferTo(final OutputStream
the output stream, non-null out)Overrides java. Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read. |
| inputStream | back to summary |
|---|---|
| private InputStream inputStream | |
| readAllBytes | back to summary |
|---|---|
| private static Method readAllBytes | |
| readNBytes1 | back to summary |
|---|---|
| private static Method readNBytes1 | |
| readNBytes3 | back to summary |
|---|---|
| private static Method readNBytes3 | |
| skipNBytes | back to summary |
|---|---|
| private static Method skipNBytes | |
| transferTo | back to summary |
|---|---|
| private static Method transferTo | |
| ProxyingInputStream | back to summary |
|---|---|
| public ProxyingInputStream(final InputStream inputStream) A proxying
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| mark | back to summary |
|---|---|
| public synchronized void mark(final int readlimit) Overrides java. Doc from java. Marks the current position in this input stream. A subsequent call to
the The The general contract of Marking a closed stream should not have any effect on the stream.
| |
| markSupported | back to summary |
|---|---|
| public boolean markSupported() Overrides java. Doc from java. Tests if this input stream supports the
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b) throws IOException Overrides java. Doc from java. Reads some number of bytes from the input stream and stores them into
the buffer array If the length of The first byte read is stored into element
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b, final int off, final int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| readAllBytes | back to summary |
|---|---|
| public byte[] readAllBytes() throws IOException Overrides java. Doc from java. Reads all remaining bytes from the input stream. This method blocks until all remaining bytes have been read and end of stream is detected, or an exception is thrown. This method does not close the input stream. When this stream reaches end of stream, further invocations of this method will return an empty byte array. Note that this method is intended for simple cases where it is convenient to read all bytes into a byte array. It is not intended for reading input streams with large amounts of data. The behavior for the case where the input stream is asynchronously closed, or the thread interrupted during the read, is highly input stream specific, and therefore not specified. If an I/O error occurs reading from the input stream, then it may do so after some, but not all, bytes have been read. Consequently the input stream may not be at end of stream and may be in an inconsistent state. It is strongly recommended that the stream be promptly closed if an I/O error occurs.
| |
| readNBytes | back to summary |
|---|---|
| public byte[] readNBytes(final int len) throws IOException Overrides java. Doc from java. Reads up to a specified number of bytes from the input stream. This method blocks until the requested number of bytes has been read, end of stream is detected, or an exception is thrown. This method does not close the input stream. The length of the returned array equals the number of bytes read
from the stream. If When this stream reaches end of stream, further invocations of this method will return an empty byte array. Note that this method is intended for simple cases where it is
convenient to read the specified number of bytes into a byte array. The
total amount of memory allocated by this method is proportional to the
number of bytes read from the stream which is bounded by The behavior for the case where the input stream is asynchronously closed, or the thread interrupted during the read, is highly input stream specific, and therefore not specified. If an I/O error occurs reading from the input stream, then it may do so after some, but not all, bytes have been read. Consequently the input stream may not be at end of stream and may be in an inconsistent state. It is strongly recommended that the stream be promptly closed if an I/O error occurs.
| |
| readNBytes | back to summary |
|---|---|
| public int readNBytes(final byte[] b, final int off, final int len) throws IOException Overrides java. Doc from java. Reads the requested number of bytes from the input stream into the given
byte array. This method blocks until In the case where end of stream is reached before If The first byte read is stored into element The behavior for the case where the input stream is asynchronously closed, or the thread interrupted during the read, is highly input stream specific, and therefore not specified. If an I/O error occurs reading from the input stream, then it may do
so after some, but not all, bytes of
| |
| reset | back to summary |
|---|---|
| public synchronized void reset() throws IOException Overrides java. Doc from java. Repositions this stream to the position at the time the
The general contract of
| |
| skip | back to summary |
|---|---|
| public long skip(final long n) throws IOException Overrides java. Doc from java. Skips over and discards
| |
| skipNBytes | back to summary |
|---|---|
| public void skipNBytes(final long n) throws IOException Overrides java. Doc from java. Skips over and discards exactly This method blocks until the requested number of bytes has been skipped, end of file is reached, or an exception is thrown. If end of stream is reached before the stream is at the desired
position, then an If an I/O error occurs, then the input stream may be in an inconsistent state. It is strongly recommended that the stream be promptly closed if an I/O error occurs.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| transferTo | back to summary |
|---|---|
| public long transferTo(final OutputStream out) throws IOException Overrides java. Doc from java. Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read. On return, this input stream will be at end of stream. This method does not close either stream. This method may block indefinitely reading from the input stream, or writing to the output stream. The behavior for the case where the input and/or output stream is asynchronously closed, or the thread interrupted during the transfer, is highly input and output stream specific, and therefore not specified.
If the total number of bytes transferred is greater than Long#MAX_VALUE, then If an I/O error occurs reading from the input stream or writing to the output stream, then it may do so after some bytes have been read or written. Consequently the input stream may not be at end of stream and one, or both, streams may be in an inconsistent state. It is strongly recommended that both streams be promptly closed if an I/O error occurs.
| |