2012-11-09 2 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 전송 자바 EOF를받을 수 있지만, 서버는 수신 할 수없는 -1서버는

가 어떻게 모든 파일을받을 수 있나요?

+0

서버 코드는 어디에 있습니까? –

+1

clientSocket이란 무엇입니까? – PeterMmm

+0

클라이언트가 -1을 보내는 것을 어떻게 알 수 있습니까? – m0skit0

답변

0

FileOutputStream을 닫기 전에 flush()를 호출하십시오.

+0

그럴 필요는 없습니다. – davmac