gpt4 book ai didi

java - "Buffer Error", "转换结果时出错 java.lang.NullPointerException : lock == null

转载 作者:太空宇宙 更新时间:2023-11-04 11:04:22 25 4
gpt4 key购买 nike

这是我的java代码,我在谷歌地图中遇到此错误

public String getJSONFromUrl(String url)
{

try {
Log.e("jsonURL", url);
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();

String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}

json = sb.toString();
is.close();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
return json;
}

我在这里调用这个方法

    protected String doInBackground(Void... params) {      
JSONParser jParser = new JSONParser();
String json = jParser.getJSONFromUrl(url);
return json;
}

请建议我解决此问题的方法。

这是网址:https://maps.googleapis.com/maps/api/directions/json?origin=30.7019818,76.6836021&destination=31.344452033528295,48.71375273913145&sensor=false&mode=driving&alternatives=true&key= google_api_key

这是日志猫

10-06 18:54:18.529 17583-18349/com.app.io.taxiapp W/System.err: Caused by: android.system.ErrnoException: connect failed: ECONNREFUSED (Connection refused) 10-06 18:54:18.529 17583-18349/com.app.io.taxiapp W/System.err: at libcore.io.Posix.connect(Native Method) 10-06 18:54:18.529 17583-18349/com.app.io.taxiapp W/System.err: at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111) 10-06 18:54:18.529 17583-18349/com.app.io.taxiapp W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:137) 10-06 18:54:18.529 17583-18349/com.app.io.taxiapp W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:122) 10-06 18:54:18.529 17583-18349/com.app.io.taxiapp W/System.err: ... 21 more 10-06 18:54:18.539 17583-17708/com.app.io.taxiapp D/libEGL: eglInitialize EGLDisplay = 0xeeafa60c 10-06 18:54:18.539 17583-17708/com.app.io.taxiapp D/libEGL: eglTerminate EGLDisplay = 0xeeafa66c 10-06 18:54:18.549 17583-17583/com.app.io.taxiapp I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@7f3946f time:11454827 10-06 18:54:18.559 17583-18349/com.app.io.taxiapp E/Buffer Error: Error converting result java.io.IOException: Attempted read on closed stream.

最佳答案

我已经解决了这个问题。实际上,我的设备中启用了数据压缩模式,这阻止了许多应用程序消耗互联网连接,谷歌播放服务也是其中之一。这就是为什么我收到此错误连接失败:ECONNREFUSED(连接被拒绝)

关于java - "Buffer Error", "转换结果时出错 java.lang.NullPointerException : lock == null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46605098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com