标签:ade url line blank 地图 ast new 方式 red
z这里用百度地图的逆地理编码接口为例,
第一种方式:(通过jdk中的java.net包)
import java.net.URL;
import java.net.URLConnection;
String url = "http://api.map.baidu.com/geocoder/v2/?" +
"callback=renderReverse&location=40.073357,116.352891&output=json&pois=0&ak=" + mapAk;
URL myURL = null;
URLConnection httpsConn = null;
myURL = new URL(url);
httpsConn = (URLConnection) myURL.openConnection();
InputStreamReader insr = null;
insr = new InputStreamReader(
httpsConn.getInputStream(), "UTF-8");
BufferedReader br = new BufferedReader(insr);
String dataStr = br.readLine();
insr.close();
第二种方式:(通过httpclient实现)
明天整理,参考如下(可点击外链)
https://my.oschina.net/u/565871/blog/701214
标签:ade url line blank 地图 ast new 方式 red
原文地址:https://www.cnblogs.com/meng-ma-blogs/p/9255309.html