67,545
社区成员




httppost = new HttpPost(URL);
//请求超时
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, nTimeout);
//读取超时
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, nTimeout);
//写入报文信息
reqEntity.addPart("body", body);
httppost.setEntity(reqEntity);
try {
response = httpclient.execute(httppost);
} catch (IOException e) {
System.out.println("read data timeout");
continue;
}
resEntity = response.getEntity();
inputStream = resEntity.getContent();
InputStreamReader reader = new InputStreamReader(inputStream ,
"UTF-8");
char[] buff = new char[1024];
int length = 0;
while ((length = reader.read(buff)) != -1) {
String x = new String(buff, 0, length);
System.out.println(x);
}