Reputation: 643
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 ?
Upvotes: 7
Views: 10677
Reputation: 23825
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");
Upvotes: 20