PostMethod post_method = new PostMethod( "http://192.168.0.1:9080/ ");
NameValuePair[] data = {
new NameValuePair( "datapack ", datapack)
};
try{
//client.executeMethod(method);
int statusCode = client.executeMethod(post_method);
if (statusCode != HttpStatus.SC_OK) {
System.err.println( "Method failed: " + post_method.getStatusLine());
}
}catch(Exception e){
System.out.println( "无效网页 ");
System.out.println(e.getMessage());
//method.releaseConnection();
post_method.releaseConnection();
return;
}
InputStream aa=post_method.getResponseBodyAsStream();
String bb=aa.toString();
aa.close();
System.out.print(bb);
post_method.releaseConnection();
返回结果是
org.apache.commons.httpclient.AutoCloseInputStream@14d3343
如果用post_method.getResponseBodyAsString();
返回结果正常
谁来拿这50分
------解决方案--------------------
InputStream txtis = post_method.getResponseBodyAsStream();
BufferedReader br = new BufferedReader(new InputStreamReader(
txtis));
String tempbf;
StringBuffer html=new StringBuffer(100);
while((tempbf=br.readLine())!=null){
html.append(tempbf);
}
System.out.println(html.toString());