Skip to content

Instantly share code, notes, and snippets.

@BDOMDev
Created June 26, 2019 08:20
Show Gist options
  • Save BDOMDev/877c747c17074a3f5fbd02b94453aa22 to your computer and use it in GitHub Desktop.
Save BDOMDev/877c747c17074a3f5fbd02b94453aa22 to your computer and use it in GitHub Desktop.
Read a file as ByteArray
@Throws(Exception::class)
fun readFile(filePath: String): ByteArray {
val file = File(filePath)
val fileContents = file.readBytes()
val inputBuffer = BufferedInputStream(
FileInputStream(file)
)
inputBuffer.read(fileContents)
inputBuffer.close()
return fileContents
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment