无法解码流:java.io.FileNotFoundException:open failed:ENOENT(没有这样的文件或目录)

时间:2014-10-22 19:40:31

标签: java httpclient

我正在尝试从Google Map API获取地点列表,但我收到以下错误消息。

执行HttpResponse时会抛出错误。

paramurl =“https://maps.googleapis.com/maps/api/place/nearbysearch/json?&location=[LAT],[LNG]&types=movie_theater&radius=5000&sensor=true&key=[API_KEY]

我已更正上面的网址,错误现已更改我已将其发布在此代码段下方。 [我删除了'&'来自... json?& location ...]。谢谢@ 323go。

   try {
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse httpResponse = httpClient.execute(new HttpGet(paramurl));
        int status = httpResponse.getStatusLine().getStatusCode();
        if (status == 200) {

            result = EntityUtils.toString(httpResponse.getEntity());
        }
    } catch (IOException e) {
        e.printStackTrace();
    **

}

这里是日志:

10-22 17:00:02.338  24247-24247/com.mussie.android.blocspot.blocspot E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: /51929ae149631b821866d0f99feccad0c41a8113: open failed: ENOENT (No such file or directory)
10-22 17:00:02.338  24247-24247/com.mussie.android.blocspot.blocspot D/AndroidRuntime﹕ Shutting down VM
10-22 17:00:02.348  24247-24247/com.mussie.android.blocspot.blocspot E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.mussie.android.blocspot.blocspot, PID: 24247
    java.lang.NullPointerException
            at com.google.j.a.cl.a(Unknown Source)
            at com.google.maps.api.android.lib6.c.cs.<init>(Unknown Source)
            at com.google.maps.api.android.lib6.c.cr.a(Unknown Source)
            at com.google.maps.api.android.lib6.c.ac.<init>(Unknown Source)
            at com.google.maps.api.android.lib6.c.ae.a(Unknown Source)
            at com.google.maps.api.android.lib6.c.dw.a(Unknown Source)
            at com.google.android.gms.maps.internal.l.onTransact(SourceFile:167)
            at android.os.Binder.transact(Binder.java:361)
            at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.addMarker(Unknown Source)
            at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)
            at com.mussie.android.blocspot.blocspot.MapsActivity$GetPOIs.onPostExecute(MapsActivity.java:435)
            at com.mussie.android.blocspot.blocspot.MapsActivity$GetPOIs.onPostExecute(MapsActivity.java:380)
            at android.os.AsyncTask.finish(AsyncTask.java:632)
            at android.os.AsyncTask.access$600(AsyncTask.java:177)
            at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

**

1 个答案:

答案 0 :(得分:1)

我在完成返回json结果的每行代码后自己解决了这个问题。

  1. 我处理了所有方法以检查服务器是否返回了记录(在这种情况下是Google Map API)

  2. 我同时要求给定地点(商场,巴士站,餐馆等)的各种数据。由于我的代码没有得到优化,所以到处都出现了问题。

  3. 我做的第三件也是最后一件事就是清理清单文件(并确保我已经准备好所有权限)。