参考文档 : https://blog.csdn.net/jfh389987366/article/details/79375527
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class Url {
public static void main(String[] args) throws Exception {
String url="http://flash.weather.com.cn/wmaps/xml/chengdu.xml";
getData(url);
}
public static String getData(String urlString) throws Exception {
String res = "";
BufferedReader reader = null;
try {
URL url = new URL(urlString);
URLConnection conn = (URLConnection)url.openConnection();
reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));