0
我使用PrintWriter輸出對象。我寫數據通過out.println(一些數據),並用out.close在嘗試從服務器獲得響應時出現EOFException
URL url = new URL(myurl);
URLConnection connection = null;
PrintWriter out = null; BufferedReader br = null; connection = url.openConnection(); connection.setDoOutput(true);
out = new PrintWriter(new OutputStreamWriter(connection.getOutputStream()),true);
while(iterations) {
//print data on writer
out.println(object);
}
//closig print writer
out.flush();
out.close();
//Response from server
br = new BufferedReader(new InputStreamReader(connection.getInputStream())); // Get Exception in //this line EOF Exception
String temp;
while(temp = br.readLine() !=null) {
//do something
}
br.close();
上傳您的代碼與錯誤代碼。 – Lucifer
結束文件異常..?也許在服務器..你是否也編碼服務器端..? – ngesh
發佈你的源代碼,你的logcat並且不僅在一個聲音中描述你的問題! –