java下载文件夹_java如何通过共享目录下载文件夹(有子文件夹)到本地目录?...
有沒有大神會操作的?
下面的代碼只能下載文件夾下只是文件的,不能下載文件夾下包含子文件夾的文件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();
}
}
總結(jié)
以上是生活随笔為你收集整理的java下载文件夹_java如何通过共享目录下载文件夹(有子文件夹)到本地目录?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ios笔试题算法_微软笔试题-Dijks
- 下一篇: 对new int[]()的理解(转载)