public final class DataSourceInputStream
extends java.io.InputStream
DataSpec
to be read from a DataSource
and
consumed through an InputStream
.Constructor and Description |
---|
DataSourceInputStream(DataSource dataSource,
DataSpec dataSpec) |
Modifier and Type | Method and Description |
---|---|
long |
bytesRead()
Returns the total number of bytes that have been read or skipped.
|
void |
close() |
void |
open()
Optional call to open the underlying
DataSource . |
int |
read() |
int |
read(byte[] buffer) |
int |
read(byte[] buffer,
int offset,
int length) |
public DataSourceInputStream(DataSource dataSource, DataSpec dataSpec)
dataSource
- The DataSource
from which the data should be read.dataSpec
- The DataSpec
defining the data to be read from dataSource
.public long bytesRead()
public void open() throws java.io.IOException
DataSource
.
Calling this method does nothing if the DataSource
is already open. Calling this
method is optional, since the read and skip methods will automatically open the underlying
DataSource
if it's not open already.
java.io.IOException
- If an error occurs opening the DataSource
.public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(@NonNull byte[] buffer) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(@NonNull byte[] buffer, int offset, int length) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException