场景:
1.获取ftp列表
2.获取文件
实现:
private static void list() { FTPClient ftpClient = new FTPClient(); try { ftpClient.connect("ftp.someabcd.com", 21); ftpClient.setControlEncoding("UTF-8"); ftpClient.login("anonymous", "anonymous@ftp.someabcd.com"); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); FTPFile[] ftpFiles = ftpClient.listFiles("/"); for (FTPFile ftpFile : ftpFiles) { System.out.println(ftpFile.getName()); } } catch (Exception e) { e.printStackTrace(); } finally { try { ftpClient.disconnect(); } catch (IOException e) { e.printStackTrace(); } } }
get文件
private static void get() { FTPClient ftpClient = new FTPClient(); OutputStream is =null; try { ftpClient.connect("ftp.someabcd.com", 21); ftpClient.setControlEncoding("UTF-8"); ftpClient.login("anonymous", "anonymous@ftp.someabcd.com"); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); File localFile = new File("G:\\a.txt"); is = new FileOutputStream(localFile); ftpClient.retrieveFile("/temp/128.139.txt", is); } catch (Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(is); try { ftpClient.disconnect(); } catch (IOException e) { e.printStackTrace(); } } }
其他常用操作:
ftpClient.dele(pathname); ftpClient.deleteFile(pathname); ftpClient.storeFile(remote, local);
相关推荐
Apache Commons是一个非常有用的工具包,解决各种实际的通用问题。(附件中提供了该工具包的jar包,及源文件以供研究) BeanUtils Commons-BeanUtils 提供对 Java 反射和自省API的包装 Betwixt Betwixt提供将 ...
很简单的代码,主要是借用了apache common开源项目的一个jar包:http://commons.apache.org/net/download_net.cgi,接下来就只要几个简单函数就可以搞定了。
使用apache的common-net.jar,实现ftp文件的上传和下载,封装成工具类,方便开发。
用于java common-net工具包编写FTP文件传输客户端的软件
apache common-net FTP Telnet SSH 等示例代码
│ │ ftp二进制与ascii传输方式区别.txt │ │ IPDeal.java │ │ Md5.java │ │ MD5Encrypt.java │ │ MyFileFilter.java │ │ PropsUtil.java │ │ RegExUtil.java │ │ SimpleConfig.java │ │ ...
,如 Apache日志档案 s (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C的日志格式)及许多其他网站,Proxy(代理服务器)、Wap、流量服务器、邮件服务器和一些 FTP服务器 . ...
//由于apache不支持中文语言环境,通过定制类解析中文日期类型 ftpClient.configure(new FTPClientConfig("com.zznode.tnms.ra.c11n.nj.resource.ftp.UnixFTPEntryParser")); FTPFile[] files = ftpClient.list...
Apache and the Internet..............................................1 Apache: The Anatomy of a Web Server.........................................................1 The Apache Source ....................
ers and architects alike can use this common language and catalog of solutions to tackle their integration problems. But although Hohpe and Woolf gave us the theory, the industry still needed an open ...
技术选型:核心框架:Sring boot + Spring Framework + Dubbo + ibase4j-common安全框架:Apache Shiro任务调度:Spring + Quartz持久层框架:MyBatis + MyBatis-Plus数据库连接池:Alibaba Druid缓存框架:Redis...