Class DataSourceInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.google.android.exoplayer2.upstream.DataSourceInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class DataSourceInputStream extends InputStream
Allows data corresponding to a givenDataSpecto be read from aDataSourceand consumed through anInputStream.
-
-
Constructor Summary
Constructors Constructor Description DataSourceInputStream(DataSource dataSource, DataSpec dataSpec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longbytesRead()Returns the total number of bytes that have been read or skipped.voidclose()voidopen()Optional call to open the underlyingDataSource.intread()intread(byte[] buffer)intread(byte[] buffer, int offset, int length)-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
DataSourceInputStream
public DataSourceInputStream(DataSource dataSource, DataSpec dataSpec)
- Parameters:
dataSource- TheDataSourcefrom which the data should be read.dataSpec- TheDataSpecdefining the data to be read fromdataSource.
-
-
Method Detail
-
bytesRead
public long bytesRead()
Returns the total number of bytes that have been read or skipped.
-
open
public void open() throws IOExceptionOptional call to open the underlyingDataSource.Calling this method does nothing if the
DataSourceis already open. Calling this method is optional, since the read and skip methods will automatically open the underlyingDataSourceif it's not open already.- Throws:
IOException- If an error occurs opening theDataSource.
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] buffer) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] buffer, int offset, int length) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
-