mirror of
https://github.com/revanced/jadb.git
synced 2024-06-02 11:26:12 +02:00
29 lines
835 B
Java
29 lines
835 B
Java
package se.vidstige.jadb;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
public class Util {
|
|
/**
|
|
* Convert an input stream to string
|
|
*
|
|
* @param inputStream input stream
|
|
*
|
|
* @return string representation of the input stream
|
|
*
|
|
* @throws IOException if an error ocurrs reading the input stream
|
|
*/
|
|
public static String inputStreamToString(InputStream inputStream) throws IOException {
|
|
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
|
byte[] buffer = new byte[1024];
|
|
int length;
|
|
while ((length = inputStream.read(buffer)) != -1) {
|
|
result.write(buffer, 0, length);
|
|
}
|
|
|
|
return result.toString(StandardCharsets.UTF_8.name());
|
|
}
|
|
}
|