oSumAtrIX 6d655b7b03 fix(twitter): make hide-ads patch compatible with any version
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-02-22 05:38:26 +01:00

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())
}
}