YafengLiang
2018-12-06 16:49:31
等
java如何通过共享目录下载文件夹(有子文件夹)到本地目录?
有没有大神会操作的?
下面的代码只能下载文件夹下只是文件的,不能下载文件夹下包含子文件夹的文件
public static void getShareFile(){ System.out.println("开始"); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("192.168.6.88","user1","voicecyber@123"); 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(); } }
评论
- 等 最代码怎么获取牛币啊?
- 完 谁来告诉我最代码上线的时间,答对者给5牛币,先来先得
- 等 牛友们,大家好,你们做程序员多久了?现在还好吗?
- 完 在微信打开的页面里进行app下载
- 等 最代码2014年欢乐聚声会
- 完 mysql如何查询表数据并且对3个字段降序的SQL?
- 完 最代码牛币机制改革
- 完 成功的在bae上使用了自定义运行环境 jetty+nginx的组合,大家对jetty+nginx优化有哪些心得?
- 完 进来分享一下各位牛牛是如何加入最代码大家庭的?
- 等 为什么java BufferedImage类处理大图直接抛出内存溢出的异常?
- 等 最代码是否开发手机app客户端?
- 完 java程序员学习哪些java的技术?java有哪些框架?都能做哪方面的开发?
- 等 php格式网页文件怎么运行?
- 等 Java volatile值获取的问题
- 等 前端vue,拦截了登录后台后,返回的token,requests拦截token,但是发送请求的时候,就出现跨越异常
- 等 大专本科计算机科班怎么找到Java工作?
- 等 eclipse怎么把三个java swing游戏项目合成一个项目?
- 完 伙伴们,大家都有什么好的解压方式么,分享一下~
- 完 三四线城市,6、7k,运维工作,索然无味,想去辞职上培训,各位牛牛有什么建议嘛
- 等 jsp页面输入中文变成问号
- 等 JPA在线上运行一段时间后报错Caused by: java.lang.IncompatibleClassChangeError: null
- 等 PHP 这个规则用preg_match_all怎么写
- 等 大佬们,有没有知道Alfresco如何配置LDAP登录呢?
- 等 php的install目录是框架带的吗?


liamhacker
2020年6月4日
暂无贡献等级
Exp丶天涯 LV8
2020年5月27日
寒江无月 LV1
2019年11月8日
cpucpa LV1
2019年5月29日
yang12 LV1
2019年4月4日
SherJ1950 LV13
2019年3月28日
wcqpg13 LV2
2019年3月7日
wgwyqq LV10
2019年3月6日
我们有一颗向往的心 LV2
2019年3月4日
2252536772 LV21
2019年2月28日