readBytes

fun File.readBytes(): ByteArray

Gets the entire content of this file as a byte array.

This method is not recommended on huge files. It has an internal limitation of 2 GB byte array size.

Return

the entire content of this file as a byte array.


@DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5")
fun InputStream.readBytes(estimatedSize: Int = DEFAULT_BUFFER_SIZE): ByteArray

Reads this stream completely into a byte array.

Note: It is the caller's responsibility to close this stream.


fun InputStream.readBytes(): ByteArray

Reads this stream completely into a byte array.

Note: It is the caller's responsibility to close this stream.

Since Kotlin

1.3

fun URL.readBytes(): ByteArray

Reads the entire content of the URL as byte array.

This method is not recommended on huge files.

Return

a byte array with this URL entire content.