FelasDroid FelasDroid - 1 year ago 119
Android Question

How i can get Response in String from Byte

i use AsyncHttpResponseHandler and i have this method:

public void onSuccess(int statusCode,
org.apache.http.Header[] headers,
byte[] responseBody) {



But now, how i can get a response in String from byte array ?

Answer Source
String str = new String(bytes, "UTF-8");

And if you're feeling lazy, you can use the Apache Commons IO library to convert the InputStream to a String directly:

String str = IOUtils.toString(inputStream, "UTF-8");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download