|
发表帖子
key: |
隐藏内容 |
产品: |
地理编码 |
请求url: |
http://restapi.amap.com/v3/geocode/geo?key=19ddf2a4aecb59947b3e1fe3f68bf52d&address=下城区朝晖街道&output=json&city=杭州市 |
url没有问题,在浏览器中可以访问,写了一个测试main函数也能用url正常返回,但是在项目中调用就是不能用,一直报位置错误 20003
public String loadJSON (String url) { URLConnection yc; StringBuilder json = new StringBuilder(); try { URL oracle = new URL(url); yc = oracle.openConnection(); yc.setUseCaches(false); BufferedReader in = new BufferedReader(new InputStreamReader( yc.getInputStream(),"UTF-8")); String inputLine = null; while ( (inputLine = in.readLine()) != null) { json.append(inputLine); } in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ System.gc(); } return json.toString(); }
|
|