mirror of
https://github.com/revanced/revanced-patches
synced 2025-02-22 15:11:10 +01:00
24 lines
699 B
Kotlin
24 lines
699 B
Kotlin
package app.revanced.twitter.utils.stream
|
|
|
|
import java.io.ByteArrayInputStream
|
|
import java.io.ByteArrayOutputStream
|
|
import java.io.IOException
|
|
import java.io.InputStream
|
|
|
|
object StreamUtils {
|
|
@Throws(IOException::class)
|
|
fun toString(inputStream: InputStream): String {
|
|
ByteArrayOutputStream().use { result ->
|
|
val buffer = ByteArray(1024)
|
|
var length: Int
|
|
while (inputStream.read(buffer).also { length = it } != -1) {
|
|
result.write(buffer, 0, length)
|
|
}
|
|
return result.toString()
|
|
}
|
|
}
|
|
|
|
fun fromString(string: String): InputStream {
|
|
return ByteArrayInputStream(string.toByteArray())
|
|
}
|
|
} |