JCIFS API
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import org.apache.commons.io.IOUtils;
public class Main {
public static void main(String[] args) throws Exception {
String srcFile = "smb://URL";
String destFile = "fileName";
String userInfo = "domain;username:password";
// The IP address of the WINS server
// jcifs.Config.setProperty( "jcifs.netbios.wins", "127.0.0.1" );
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(userInfo);
SmbFile f = new SmbFile(srcFile, auth);
InputStream is = f.getInputStream();
try {
OutputStream os = new FileOutputStream(destFile);
try {
IOUtils.copy(is, os);
} finally {
os.close();
}
} finally {
is.close();
}
}
}
沒有留言:
張貼留言