1
當我嘗試在HttpResponse
上使用BufferedReader
時,我收到「SocketException:Bad file number」。 基本上我試着解析我的服務器響應。奇怪的是,它只發生在我的LG 2x(Android 2.2.2)上,我沒有在Android模擬器(Google 2.2)和HTC(2.2)上看到這個錯誤。SocketException:錯誤的文件號。我該如何解決它?
In this thread someone explained why the error occurs.但是爲什麼這個問題只發生在LG手機上,更重要的是,我該如何解決呢?
HttpResponse response = JSONHelper.postJSONObject(WebSMSActivity.this, Consts
.api_url("settings"), json,
"Registration");
// Read the response for the JSON reply
try {
BufferedReader in = new BufferedReader(
new InputStreamReader(response.getEntity().getContent(), "UTF-8"), 8 * 1024);
// Read every line (should actually only be
// one
StringBuilder builder = new StringBuilder();
for (String line = null; (line = in.readLine()) != null;) {
builder.append(line).append("\n");
Log.w(Consts.LOG_TAG_SERVICE, line);
}
String textResponse = builder.toString(); } catch (IOException ex) {}