首页 > 其他 > 详细

天气预报接口

时间:2020-01-20 15:48:27      阅读:82      评论:0      收藏:0      [点我收藏+]

中华万年历api

 

public static String GetWeatherData(String cityname) {
StringBuilder sb=new StringBuilder();
try {
String weatherUrl = "http://wthrcdn.etouch.cn/weather_mini?city="+cityname;


URL url = new URL(weatherUrl);
URLConnection conn = url.openConnection();
InputStream inputStream = conn.getInputStream();
GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream);
// 设置读取流的编码格式,自定义编码
InputStreamReader inputStreamReader = new InputStreamReader(gzipInputStream, "utf-8");
BufferedReader reader = new BufferedReader(inputStreamReader);
String line = null;
while((line=reader.readLine())!=null)
sb.append(line+" ");
reader.close();
} catch (Exception e) {
System.out.println("异常了");
e.printStackTrace();
}
return sb.toString();

}

天气预报接口

原文:https://www.cnblogs.com/changefl/p/12218210.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!