Created
September 30, 2021 22:37
-
-
Save eldetulado/9e79ffed1831c1003300a5bfbf2304ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private fun convertStreamToString(inputStream: InputStream): String { | |
val reader = BufferedReader(InputStreamReader(inputStream, "utf-8")) | |
val sb = StringBuilder() | |
var line: String? | |
try { | |
while (reader.readLine().also { line = it } != null) { | |
sb.append(line) | |
} | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} finally { | |
inputStream.close() | |
} | |
return sb.toString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment