Going to buffer response body of large or unknown size.Using getResponseBodyAsStream instead is recommened

原始写法

byte[] responseBody=postMethod.getResponseBody()
String result=new String("","UTF-8");

  更换为

InputStream inputStream = postMethod.getResponseBodyAsStream();
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
            StringBuffer stringBuffer = new StringBuffer();
            String str = "";
            while ((str = br.readLine()) != null) {
                stringBuffer.append(str);
            }
           String result=stringBuffer.toString();

  

 

posted @ 2022-07-21 15:35  不忘初心2021  阅读(76)  评论(0编辑  收藏  举报