다음 오류가 발생했습니다. java.lang.NullPointerException : lock == null 서버에서 json 파일을 가져 오는 동안. google하지만 위의 모든 솔루션을 찾을 수 없습니다.java.lang.NullPointerException : 서버에서 json 파일을 가져 오는 동안 잠금 == null
내 코드 :
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
Log.i("clock", httpPost.getURI().toString());
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 {
Log.i("Buffer", "1");
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
Log.i("Buffer", "2");
StringBuilder sb = new StringBuilder();
Log.i("Buffer", "3");
String line = null;
Log.i("Buffer", "4");
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
Log.i("Buffer", "5");
json = sb.toString();
Log.i("Buffer", "6->"+json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result-> " + e.toString());
}
로그 캣 :
날 위해 일했습니다. – assylias
전체 logcat 게시물을 게시하십시오. AndroidManifest.xml 파일에 인터넷 권한을 추가했는지 확인하십시오. – rajpara