@@ -0,0 +1,1593 @@
+package lemon.shared.toolkit;%0D%0A%0D%0Aimport java.io.BufferedReader;%0D%0Aimport java.io.IOException;%0D%0Aimport java.io.InputStream;%0D%0Aimport java.io.InputStreamReader;%0D%0Aimport java.net.HttpURLConnection;%0D%0Aimport java.net.URL;%0D%0A%0D%0Apublic class Weather %7B%0D%0A%09public static String test(String urlStr) throws IOException %7B%0D%0A%09%09URL url = new URL(urlStr);%0D%0A%09%09HttpURLConnection con = null;%0D%0A%09%09try %7B%0D%0A%09%09%09con = (HttpURLConnection) url.openConnection();%0D%0A%09%09%09con.setRequestMethod(%22GET%22);%0D%0A%09%09%09con.setConnectTimeout(5000);%0D%0A%0D%0A%09%09%09con.setDoOutput(false);%0D%0A%09%09%09// get reply message%0D%0A%09%09%09return getReceive(con);%0D%0A%09%09%7D finally %7B%0D%0A%09%09%09if (con != null)%0D%0A%09%09%09%09con.disconnect();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09private static String getReceive(HttpURLConnection con) throws IOException %7B%0D%0A%09%09InputStream is = null;%0D%0A%09%09try %7B%0D%0A%09%09%09is = con.getInputStream();%0D%0A%09%09%09BufferedReader br = new BufferedReader(new InputStreamReader(is,%0D%0A%09%09%09%09%09%22UTF-8%22));%0D%0A%09%09%09StringBuffer sb = new StringBuffer();%0D%0A%09%09%09String line;%0D%0A%09%09%09while ((line = br.readLine()) != null)%0D%0A%09%09%09%09sb.append(line);%0D%0A%09%09%09return sb.toString();%0D%0A%09%09%7D finally %7B%0D%0A%09%09%09if (null != is)%0D%0A%09%09%09%09is.close();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A%09public static void main(String%5B%5D args) throws IOException%7B%0D%0A%09%09String cityid = %22101310204%22;%0D%0A%09%09String url = %22http://m.weather.com.cn/data5/city.xml%22;%0D%0A%09%09System.out.println(test(url));%0D%0A%09%09String%5B%5D citys = test(url).split(%22,%22);%0D%0A%09%09for (String str : citys) %7B%0D%0A%09%09%09String provinceCode = %22310501%22;%0D%0A%09%09%09url = %22http://m.weather.com.cn/data5/city%22+provinceCode+%22.xml%22;%0D%0A%09%09%09System.out.println(test(url));%0D%0A%09%09%7D%0D%0A%09%09url = %22http://m.weather.com.cn/data/%22+cityid+%22.html%22;%0D%0A%09%09System.out.println(test(url));%0D%0A%09%7D%0D%0A%7D%0D%0A

添加天气查询API。