| Modifier and Type | Field and Description |
|---|---|
| pack-priv ByteBuffer | |
| private static final ByteBuffer | |
| private static final byte[] | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| public | MemoryInputStream(final ByteBuffer
the byte buffer containing the stream data (must not be buffer)null)Construct a new instance for a byte buffer. |
| public | MemoryInputStream(final byte[]
the byte array (must not be bytes)null)Construct a new instance for a byte array. |
| 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. |
| private static void | |
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| public void | mark(final int
the maximum limit of bytes that can be read before
the mark position becomes invalid. bytes)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, 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 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 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. |
| buf | back to summary |
|---|---|
| pack-priv ByteBuffer buf | |
| CLOSED | back to summary |
|---|---|
| private static final ByteBuffer CLOSED | |
| EMPTY_BYTES | back to summary |
|---|---|
| private static final byte[] EMPTY_BYTES | |
| mark | back to summary |
|---|---|
| pack-priv int mark | |
| MemoryInputStream | back to summary |
|---|---|
| public MemoryInputStream(final ByteBuffer buffer) Construct a new instance for a byte buffer. The given buffer contents are not copied. Consuming the stream will not affect the buffer's position or limit. Modifying the buffer's position or limit will not affect operation of the stream.
| |
| MemoryInputStream | back to summary |
|---|---|
| public MemoryInputStream(final byte[] bytes) Construct a new instance for a byte array. The byte array is not copied.
| |
| available | back to summary |
|---|---|
| public int available() 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
| |
| checkClosed | back to summary |
|---|---|
| private static void checkClosed(final ByteBuffer buf) throws IOException | |
| close | back to summary |
|---|---|
| public void close() 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 void mark(final int bytes) 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, 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.
| |
| reset | back to summary |
|---|---|
| public 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
| |
| 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.
| |