ChunkedInput that fetches data from an InputStream chunk by
chunk.
Please note that the InputStream instance that feeds data into
ChunkedStream must implement InputStream#available() as
accurately as possible, rather than using the default implementation.
Otherwise, ChunkedStream will generate many too small chunks or
block unnecessarily often.
| Modifier and Type | Field and Description |
|---|---|
| private byte[] | |
| private final int | |
| private boolean | |
| pack-priv static final int | |
| private final PushbackInputStream | |
| private long |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ChunkedStream(InputStream in, int
the number of bytes to fetch on each chunkSize)readChunk(BufferAllocator) call.Creates a new instance that fetches data from the specified stream. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. |
| public boolean | isEndOfInput()
Implements io. true if and only if there is no data left in the stream
and the stream has reached at its end.
|
| public long | |
| public long | progress()
Implements io. |
| public Buffer | readChunk(BufferAllocator
BufferAllocator if buffer allocation is necessary.Implements io. |
| public long |
| cachedArray | back to summary |
|---|---|
| private byte[] cachedArray | |
| chunkSize | back to summary |
|---|---|
| private final int chunkSize | |
| closed | back to summary |
|---|---|
| private boolean closed | |
| DEFAULT_CHUNK_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_CHUNK_SIZE | |
| in | back to summary |
|---|---|
| private final PushbackInputStream in | |
| offset | back to summary |
|---|---|
| private long offset | |
| ChunkedStream | back to summary |
|---|---|
| public ChunkedStream(InputStream in) Creates a new instance that fetches data from the specified stream. | |
| ChunkedStream | back to summary |
|---|---|
| public ChunkedStream(InputStream in, int chunkSize) Creates a new instance that fetches data from the specified stream.
| |
| close | back to summary |
|---|---|
| public void close() throws Exception Implements java. Doc from java. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
| |
| isEndOfInput | back to summary |
|---|---|
| public boolean isEndOfInput() throws Exception Implements io. Doc from io. Return
| |
| length | back to summary |
|---|---|
| public long length() Implements io. Doc from io. Returns the length of the input.
| |
| progress | back to summary |
|---|---|
| public long progress() Implements io. Doc from io. Returns current transfer progress.
| |
| readChunk | back to summary |
|---|---|
| public Buffer readChunk(BufferAllocator allocator) throws Exception Implements io. Doc from io. Fetches a chunked data from the stream. Once this method returns the last chunk
and thus the stream has reached at its end, any subsequent
| |
| transferredBytes | back to summary |
|---|---|
| public long transferredBytes() Returns the number of transferred bytes. | |