jadb/src/se/vidstige/jadb/Util.java
Daniel Llewellyn 01b5022d65 Adding the ability to enable tcpip from the jadb
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()```
2019-01-06 12:18:38 +00:00

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