Modifier and Type | Field and Description |
---|---|
private byte[] | |
private ByteBuffer | |
private byte[] | |
private final ReadableByteChannel | |
private static final int |
Access | Constructor and Description |
---|---|
pack-priv | ChannelInputStream(ReadableByteChannel ch)
Initialize a ChannelInputStream that reads from the given channel. |
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. |
private int | |
public synchronized int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
public synchronized int | read(byte[]
the buffer into which the data is read. bs, int the start offset in array off, 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(int
the maximum number of bytes to read len)Overrides java. Reads up to a specified number of bytes from the input stream. |
public synchronized long | skip(long
the number of bytes to be skipped. n)Overrides java. Skips over and discards |
private static long | transfer(FileChannel fc, WritableByteChannel target)
Transfers all bytes from a channel's file to a target writeable byte channel. |
private static long | transfer(ReadableByteChannel src, FileChannel dst)
Transfers all bytes from a readable byte channel to a target channel's file. |
public long | transferTo(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. |
b1 | back to summary |
---|---|
private byte[] b1 |
bb | back to summary |
---|---|
private ByteBuffer bb |
bs | back to summary |
---|---|
private byte[] bs |
ch | back to summary |
---|---|
private final ReadableByteChannel ch |
DEFAULT_BUFFER_SIZE | back to summary |
---|---|
private static final int DEFAULT_BUFFER_SIZE |
ChannelInputStream | back to summary |
---|---|
pack-priv ChannelInputStream(ReadableByteChannel ch) Initialize a ChannelInputStream that reads from the given channel. |
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.
|
read | back to summary |
---|---|
private int read(ByteBuffer bb) throws IOException Reads a sequence of bytes from the channel into the given buffer. |
read | back to summary |
---|---|
public synchronized 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 synchronized int read(byte[] bs, int off, 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(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.
|
skip | back to summary |
---|---|
public synchronized long skip(long n) throws IOException Overrides java. Doc from java. Skips over and discards
|
transfer | back to summary |
---|---|
private static long transfer(FileChannel fc, WritableByteChannel target) throws IOException Transfers all bytes from a channel's file to a target writeable byte channel. If the writeable byte channel is a selectable channel then it must be in blocking mode. |
transfer | back to summary |
---|---|
private static long transfer(ReadableByteChannel src, FileChannel dst) throws IOException Transfers all bytes from a readable byte channel to a target channel's file. If the readable byte channel is a selectable channel then it must be in blocking mode. |
transferTo | back to summary |
---|---|
public long transferTo(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.
|