日期:2014-05-17 浏览次数:20978 次
FtpServerFactory serverFactory = new FtpServerFactory(); //监听 ListenerFactory factory = new ListenerFactory(); factory.setPort(2121); serverFactory.addListener("default", factory.createListener()); PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory(); userManagerFactory.setFile(new File("D:/users.properties")); /**使用自己的加密类,因为apache ftp server 使用的是md5 也就是logon之前需把密码加密后才能logon */ // userManagerFactory.setPasswordEncryptor(new LocalPassword()); serverFactory.setUserManager(userManagerFactory.createUserManager()); //创建服务并启动 FtpServer server = serverFactory.createServer(); try { server.start(); } catch (FtpException e) { e.printStackTrace(); }