有没有大神会操作的?
下面的代码只能下载文件夹下只是文件的,不能下载文件夹下包含子文件夹的文件public static void getShareFile(){
System.out.println("开始");
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("192.168.6.88","user1","[email protected]");
String url = "smb://192.168.6.88/tomcat/";
try{
SmbFile file = new SmbFile(url,auth);
if(file.exists()){
SmbFile[] files = file.listFiles();
for(SmbFile f : files){
String localDir = "F:\\vcc\\";
InputStream in = new BufferedInputStream(new SmbFileInputStream(f));
File localFile = new File(localDir + File.separator + f.getName());
OutputStream out = new BufferedOutputStream(new FileOutputStream(localFile));
System.out.println(f.getContentLength());
byte[] buffer = new byte[1024];
while(in.read(buffer) != -1){
out.write(buffer);
buffer = new byte[1024];
}
in.close();
out.close();
}
}else {
logger.info("共享目录不存在");
}
}catch(Exception e){
e.printStackTrace();
}
}