第1个回答 推荐于2016-07-30
url = new URL(url)
httpurlconnection = (HttpURLConnection) url.openConnection();
httpurlconnection.setDoOutput(true);
httpurlconnection.setRequestMethod("POST");
httpurlconnection.connect();
httpurlconnection.getOutputStream().write(param.getBytes("GBK"));
httpurlconnection.getOutputStream().flush();
httpurlconnection.getOutputStream().close();
in = httpurlconnection.getInputStream();
if (in == null) {
log.info("========调用HTTP接口出错=======");
throw new Exception("调用HTTP接口出错 ");
}
BufferedReader breader = new BufferedReader(new InputStreamReader(
in, "GBK"));
String str = breader.readLine();
String returnStr = null;
while (str != null) {
if (returnStr == null) {
returnStr = str;
} else {
returnStr += str;
}
str = breader.readLine();
if (str == null) {
break;
}
大概这个样子本回答被提问者和网友采纳