URL url = new URL("http://ditu.google.com/maps/api/geocode/json?latlng=31.1899209667,121.3918055000&sensor=false&&language=zh-CN");
URLConnection conn = url.openConnection();
HttpURLConnection http = (HttpURLConnection)conn;
http.setRequestMethod("GET");
http.setDoInput(true);
http.setDoOutput(true);
http.setRequestProperty("Accept-Charset", "UTF-8");
http.connect();
// System.out.println(http.getContentType());
InputStream in = http.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));
String s = null;
String json = "";
while((s = br.readLine()) != null) {
json+=s;
}
org.json.JSONObject jo = new org.json.JSONObject(json);
org.json.JSONArray ja = jo.getJSONArray("results");
org.json.JSONObject jo1 = ja.getJSONObject(0);
System.out.println(jo1.getString("formatted_address"));
System.out.println(json);