@UnstableApi
class DataSourceUtil


Utility methods for DataSource.

Summary

Public functions

java-static Unit
closeQuietly(dataSource: DataSource?)

Closes a DataSource, suppressing any IOException that may occur.

java-static ByteArray<Byte>!
readExactly(dataSource: DataSource!, length: Int)

Reads length bytes from the specified opened DataSource, and returns a byte array containing the read data.

java-static ByteArray<Byte>!
readToEnd(dataSource: DataSource!)

Reads data from the specified opened DataSource until it ends, and returns a byte array containing the read data.

Public functions

closeQuietly

java-static fun closeQuietly(dataSource: DataSource?): Unit

Closes a DataSource, suppressing any IOException that may occur.

Parameters
dataSource: DataSource?

The DataSource to close.

readExactly

java-static fun readExactly(dataSource: DataSource!, length: Int): ByteArray<Byte>!

Reads length bytes from the specified opened DataSource, and returns a byte array containing the read data.

Parameters
dataSource: DataSource!

The source from which to read.

length: Int

The number of bytes to read.

Returns
ByteArray<Byte>!

The read data.

Throws
java.io.IOException

If an error occurs reading from the source.

java.lang.IllegalStateException

If the end of the source was reached before length bytes could be read.

readToEnd

java-static fun readToEnd(dataSource: DataSource!): ByteArray<Byte>!

Reads data from the specified opened DataSource until it ends, and returns a byte array containing the read data.

Parameters
dataSource: DataSource!

The source from which to read.

Returns
ByteArray<Byte>!

The concatenation of all read data.

Throws
java.io.IOException

If an error occurs reading from the source.