Java HttpGet

String urlStr ="https://qyapi.weixin.qq.com/cgi-bin/gettoken?a=a&b=b";
URL url = null;
BufferedReader in = null;
StringBuffer sb = new StringBuffer();
try {
url = new URL(urlStr);
in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));
String str = null;
while ((str = in.readLine()) != null) {
sb.append(str);
}
} catch (Exception ex) {

} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
}
}
System.out.println(sb.toString());

原文地址:https://www.cnblogs.com/catzhou/p/5224344.html