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, reset
public 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 InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public int available()
available
in class InputStream
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream