mirror of
https://github.com/revanced/jadb.git
synced 2024-06-02 11:26:12 +02:00
01b5022d65
Using the information from https://github.com/aosp-mirror/platform_system_core/blob/master/adb/daemon/services.cpp for the spec on how to construct the response. Usage is simply ```JadbDevice jadbDevice = ...; jadbDevice.enableTcpip()```
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());
|
|
}
|
|
}
|