DataSourceInputStream


@UnstableApi
class DataSourceInputStream : 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 functions

Long

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

Unit
Unit

Optional call to open the underlying DataSource.

Int
Int
read(buffer: ByteArray!)
Int
read(buffer: ByteArray!, offset: Int, length: Int)

Inherited functions

From java.io.InputStream
Int
synchronized Unit
mark(readlimit: Int)
Boolean
java-static InputStream!
ByteArray<Byte>!
ByteArray<Byte>!
Int
readNBytes(b: ByteArray!, off: Int, len: Int)
synchronized Unit
Long
skip(n: Long)
Unit
Long

Public constructors

DataSourceInputStream

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 functions

bytesRead

fun bytesRead(): Long

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

close

fun close(): Unit

open

fun open(): Unit

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

fun read(): Int

read

fun read(buffer: ByteArray!): Int

read

fun read(buffer: ByteArray!, offset: Int, length: Int): Int