@Test
public void demo6() throws Exception {
URL url = new URL("http://wthrcdn.etouch.cn/weather_mini?citykey="+"101120201");
URLConnection openConnection = url.openConnection();
openConnection.setReadTimeout(2000);
openConnection.setConnectTimeout(2000);
InputStream inputStream = openConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader br = new BufferedReader(inputStreamReader);
StringBuffer sb = new StringBuffer();
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line);
System.err.println(line);
}
String datas = new String();
System.err.println(datas);
}
java 天气接口
最新推荐文章于 2022-09-01 14:00:33 发布