2012-11-09 74 views
0
FileOutputStream fos = new FileOutputStream(fileName); 
InputStream is = clientSocket.getInputStream(); 
while ((readBytes = is.read()) != -1) 
{ 
    fos.write(readBytes); 
    System.err.println(readBytes); 
} 
System.err.println(readBytes); 
clientSocket.shutdownOutput(); 
fos.close(); 
System.out.println("Trans complete"); 

客戶端發送-1,但服務器無法接收-1服務器無法接收EOF在Java

我怎樣才能得到所有的文件

+0

你的服務器代碼在哪裏? – 2012-11-09 10:21:59

+1

什麼是clientSocket? – PeterMmm

+0

你怎麼知道客戶端發送-1? – m0skit0

回答

0

在關閉FileOutputStream之前調用flush()。

+0

這沒有必要。 – davmac

相關問題