我試圖用這段代碼將文件從我的電腦傳輸到另一臺電腦,但我得到 異常java.io.FileNotFoundException:\ 192.168.1.4 \ D:\ Color.txt(無法找到網絡名稱)如何將文件從一臺電腦複製到另一臺電腦
File source = new File("G:\\Color.txt");
File dest = new File("\\\\192.168.1.4\\D:\\Color.txt");
// File dest = new File("D:\\Color.txt");
try {
InputStream input = new FileInputStream(source);
OutputStream output = new FileOutputStream(dest);
byte[] buf = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buf)) > 0) {
output.write(buf, 0, bytesRead);
}
System.out.println("File Copied successfully");
input.close();
output.close();
}
catch(Exception e)
{
System.out.println("Exception "+e);
}
當您在資源管理器中手動寫入時,它會連接嗎? – 2015-03-31 09:09:47