public class ByteSource2InputStream extends InputStream
This is useful to pass a ByteSource to a legacy API that accepts InputStream.
CAUTION: InputStream.read() usually blocks; a method that accepts an InputStream is usually a blocking method. Keep that in mind when building a non-blocking app.
| Constructor and Description |
|---|
ByteSource2InputStream(ByteSource origin,
Duration readTimeout)
Create an InputStream based on the ByteSource.
|
| Instance Methods | |
|---|---|
int |
read(byte[] dst,
int off,
int len) |
int |
read() |
long |
skip(long n) |
int |
available() |
void |
close() |
mark, markSupported, read, resetpublic ByteSource2InputStream(ByteSource origin, Duration readTimeout)
readTimeout - timeout for reading the origin ByteSource.public int read(byte[] dst,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic int available()
available in class InputStreampublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class InputStream