2011-12-14 347 views

回答

1

這就是:

Socket socket = new Socket(host, port); 
FileInputStream fis = new FileInputStream(yourFile); 
OutputStream out = socket.getOutputStream(); 
byte[] buffer = new byte[9182]; 
int nBytesRead = 0; 
while ((nBytesRead = fis.read(buffer) != -1) 
{ 
    out.write(buffer, 0, nBytesRead); 
} 
out.flush(); 
out.close(); 
fis.close(); 
+0

我如何重新收集數據? –

+0

谷歌也知道這一點:嘗試谷歌「Java套接字文件傳輸」 –