FelasDroid
FelasDroid

Reputation: 643

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 ?

Upvotes: 7

Views: 10677

Answers (1)

Muhammad Kashif Nazar
Muhammad Kashif Nazar

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

Related Questions