我試圖使用JCIFS將一些遠程文件複製到Java本地驅動器。 遠程機器在域內。本地機器在域中是而不是。如何將文件從SMB共享複製到本地驅動器不在與JCIFS的域中
下面的代碼工作,但它是真的慢(2分鐘,700KB ...我有許多MB ...):
SmbFile remoteFile = new SmbFile("smb://...")
OutputStream os = new FileOutputStream("/path/to/local/file");
InputStream is = remoteFile.getInputStream();
int ch;
while ((ch = is.read()) != -1) {
os.write(ch);
}
os.close();
is.close();
我想我可以使用SmbFile.copyTo() ,但我不知道如何訪問本地文件。如果我寫了下面,我得到一個連接錯誤:
localfile = new SmbFile("file:///path/to/localfile")
這個問題是關係到How to copy file from smb share to local drive using jcifs in Java?
值得注意的是,nagualjj表示你也可以使用格式「C:/ path/to/file」,但是我沒有成功這樣做。 http://stackoverflow.com/questions/13359164/ – jonnybot
什麼是'remoteFile'? – Jaikrat
從最初的問題來看,'remoteFile'是OP要複製到另一個位置(在本例中爲'myFile')的SmbFile。 – jonnybot