How to print out returned message from HttpResponse?

前端 未结 5 1258
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 16:16

I have this code on my Android phone.

   URI uri = new URI(url);
   HttpPost post = new HttpPost(uri);
   HttpClient client = new DefaultHttpClient();
   Htt         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 16:25

    I would just do it the old way. It's a more bulletproof than ResponseHandler, in case you get different content types in the response.

    ByteArrayOutputStream outstream = new ByteArrayOutputStream();
    response.getEntity().writeTo(outstream);
    byte [] responseBody = outstream.toByteArray();
    

提交回复
热议问题