Created
June 26, 2019 08:20
-
-
Save BDOMDev/877c747c17074a3f5fbd02b94453aa22 to your computer and use it in GitHub Desktop.
Read a file as ByteArray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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