I'm trying to copy some remote files to the local drive, in Java, using JCIFS. The remote machine is inside a domain. The local machine is not in a domain.
The following code works, but it's really slow (2 minutes for 700Kb... and I have many 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();
I think I could use SmbFile.copyTo(), but I don't know how to access the local file. If I write the following, I get a connection error:
localfile = new SmbFile("file:///path/to/localfile")
This question is related to How to copy file from smb share to local drive using jcifs in Java?