InputStream To Bytearray And String (Kotlin)

April 20, 2018
val outputStream = ByteArrayOutputStream()
inputStream.use { input ->
    outputStream.use { output ->
        input.copyTo(output)
    }
}
val byteArray = outputStream.toByteArray()
val outputString = String(byteArray, Charsets.UTF_8)
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.