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();