public static String getResult(String order) {
String result = "";
String URL = "http://xxx.com";
try {
URL url = new URL(URL);
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
InputStreamReader bis = new InputStreamReader(httpURLConnection
.getInputStream(), "utf-8");
int c = 0;
while ((c = bis.read()) != -1) {
result = result + (char) c;
}
} catch (Exception e) {
log.debug(""+e.getMessage());
e.printStackTrace();
}
return result;
}
调用网络接口并读取返数据
最新推荐文章于 2022-04-24 15:19:14 发布