public class InputStream2ByteSource extends Object implements ByteSource
This is useful to use a legacy InputStream in an async, non-blocking app.
CAUTION: creating an InputStream in the first place might be a blocking action; keep that in mind when building a non-blocking app.
| Constructor and Description |
|---|
InputStream2ByteSource(InputStream inputStream,
int bufferSize)
Creating a ByteSource based on the InputStream.
|
| Instance Methods | |
|---|---|
Async<ByteBuffer> |
read()
Read the next chunk of bytes.
|
long |
skip(long n)
Try to skip forward `n` bytes.
|
Async<Void> |
close()
Close this source.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasString, asString, readAll, toSinkpublic InputStream2ByteSource(InputStream inputStream, int bufferSize)
bufferSize - preferred buffer size for readpublic Async<ByteBuffer> read() throws IllegalStateException
read in interface ByteSourceIllegalStateException - if this source is closed.public long skip(long n)
throws IllegalArgumentException,
IllegalStateException
skip in interface ByteSourcen - number of bytes to skip; n >= 0.0 <= m <= n.IllegalStateException - if this source is closed.IllegalArgumentException - if n < 0.public Async<Void> close()
close in interface ByteSource