FelasDroid FelasDroid - 4 months ago 27
Android Question

How i can get Response in String from Byte

i use AsyncHttpResponseHandler and i have this method:

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

showProgress(false);



}


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

Answer
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");