FTP客户端Java开源类库 edtFTPj 2.3.0 发布
admin 13年前
<p><a href="http://www.open-open.com/open79635.htm" target="_blank">edtFTPj</a>是一个FTP客户端库,可让任何Java应用程序能有充分的嵌入式FTP功能。它包括一个易于使用的API的方法,如 downloadFile() 和uploadFile() 。大多数FTP命令的支持,并主动和被动模式。 edFTPj已被广泛的测试,并已广泛应用于成千上万的项目。<br /> 示例代码:</p> <pre class="brush:java; toolbar: true; auto-links: false;">/* * * Copyright (C) 2006 Enterprise Distributed Technologies Ltd * * www.enterprisedt.com */ import com.enterprisedt.net.ftp.FileTransferClient; import com.enterprisedt.util.debug.Level; import com.enterprisedt.util.debug.Logger; public class ConnectToServer { public static void main(String[] args) { // we want remote host, user name and password if (args.length < 3) { System.out .println("Usage: run remote-host username password"); System.exit(1); } // extract command-line arguments String host = args[0]; String username = args[1]; String password = args[2]; // set up logger so that we get some output Logger log = Logger.getLogger(ConnectToServer.class); Logger.setLevel(Level.INFO); FileTransferClient ftp = null; try { // create client log.info("Creating FTP client"); ftp = new FileTransferClient(); // set remote host log.info("Setting remote host"); ftp.setRemoteHost(host); ftp.setUserName(username); ftp.setPassword(password); // connect to the server log.info("Connecting to server " + host); ftp.connect(); log.info("Connected and logged in to server " + host); // Shut down client log.info("Quitting client"); ftp.disconnect(); log.info("Example complete"); } catch (Exception e) { e.printStackTrace(); } } }</pre> <p></p> <p><strong>变化:</strong></p> <p>1. Support was added for using ACCT in FileTransferClient. <br /> 2. FTPFile.getPath() no longer includes the filename. <br /> 3. A bug was fixed in MLST parser. <br /> 4. An empty array of features is returned<span class="truncate_more"> if FEAT returns no features (but is implemented by the server). <br /> 5. The array is tweaked so that only actual features are returned</span></p>