spring-framework / org.springframework.util / FileCopyUtils / copyToByteArray

copyToByteArray

open static fun copyToByteArray(in: File): ByteArray

Copy the contents of the given input File into a new byte array.

Parameters

in - the file to copy from

Exceptions

IOException - in case of I/O errors

Return
the new byte array that has been copied to

open static fun copyToByteArray(@Nullable in: InputStream): ByteArray

Copy the contents of the given InputStream into a new byte array. Closes the stream when done.

Parameters

in - the stream to copy from (may be null or empty)

Exceptions

IOException - in case of I/O errors

Return
the new byte array that has been copied to (possibly empty)