设为首页 加入收藏

TOP

FTPClientUtil FTP客户端工具(三)
2015-07-20 17:58:28 来源: 作者: 【 】 浏览:9
Tags:FTPClientUtil FTP 客户端 工具
6309\u5728\u670D\u52A1\u7AEF\u7684\u8DEF\u5F84\u5728\u6307\u5B9A\u672C\u5730\u8DEF\u5F84\u4E0B\u521B\u5EFA\u60F3\u5BF9\u5E94\u7684\u8DEF\u5F84\u548C\u6587\u4EF6 * @param localPath * \u672C\u5730\u8DEF\u5F84 * @return * @throws Exception */ public static boolean downloadToLocal2(String filename, String localPath) throws Exception { List list=listNames(); OutputStream out; try{ for(Iterator it=list.iterator();it.hasNext();){ String filepath=it.next(); if(filepath.contains(filename)){ String remoteFilePath=filepath.substring(1, filepath.length()); File file=new File(localPath+remoteFilePath); new File(file.getParent()).mkdirs(); out= new FileOutputStream(localPath+remoteFilePath); getFTPClient().retrieveFile(filepath, out); // \u4E0B\u8F7D out.close(); } } return true; }catch (Exception e) { return false; } } /** * @description \u521B\u5EFA\u8FDC\u7A0B\u76EE\u5F55\u5141\u8BB8\u521B\u5EFA\u591A\u7EA7\u76EE\u5F55 * @param remoteDir \u8FDC\u7A0B\u76EE\u5F55 * @return * @throws SocketException * @throws IOException * @throws FTPClientException */ public static boolean mkdirs(String remoteDir) throws SocketException, IOException, FTPClientException{ String[] dirs=remoteDir.split("/"); String remotePath="."; for(String dir:dirs){ if(!dir.equals(".")&&null!=dir){ remotePath=remotePath+File.separator+dir+File.separator; boolean result=getFTPClient().makeDirectory(remotePath); if(!result){ return result; } } } return true; } }
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 1754 I Hate It (线段树) 下一篇HDU 3065 病毒侵袭持续中 AC自动..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: