DataSourceInputStream

@UnstableApi
public final class DataSourceInputStream extends InputStream


Allows data corresponding to a given DataSpec to be read from a DataSource and consumed through an InputStream.

Summary

Public constructors

DataSourceInputStream(DataSource dataSource, DataSpec dataSpec)

Public methods

long

Returns the total number of bytes that have been read or skipped.

void
void

Optional call to open the underlying DataSource.

int
int
read(byte[] buffer)
int
read(byte[] buffer, int offset, int length)

Inherited methods

From java.io.InputStream
int
synchronized void
mark(int readlimit)
boolean
static InputStream
byte[]
byte[]
readNBytes(int len)
int
readNBytes(byte[] b, int off, int len)
synchronized void
long
skip(long n)
void
skipNBytes(long n)
long

Public constructors

DataSourceInputStream

public DataSourceInputStream(DataSource dataSource, DataSpec dataSpec)
Parameters
DataSource dataSource

The DataSource from which the data should be read.

DataSpec dataSpec

The DataSpec defining the data to be read from dataSource.

Public methods

bytesRead

public long bytesRead()

Returns the total number of bytes that have been read or skipped.

close

public void close()

open

public void open()

Optional call to open the underlying 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.

Throws
java.io.IOException

If an error occurs opening the DataSource.

read

public int read()

read

public int read(byte[] buffer)

read

public int read(byte[] buffer, int offset, int length)