ftpClient = new FtpClient(ip) 报错 cannot instantiate the type FtpClient

sun.net.ftp.FtpClient 这个类在jdk的帮助文档中没有具体的说明,也就是并没有对外公开。

并且这个类是在jdk的 rt.jar中实现的。

jdk1.7下其构造函数FtpClient()被定义为private类型, 所以无法new了。 在jdk1.7,已经换成了 FtpClient.create(ip)方法
同时,其他的一些方法也基本都改掉了,
如 ftpClient.openServer(server);
  ftpClient.login(user, password);
就可以换成:ftpClient.login(user, null, password);   
  ftpClient.binary();  --->  ftpClient.setBinaryType();   
ftpClient.put(remotefilename);--->ftpClient.putFileStream(remotefilename, true);   
等。
posted @ 2017-07-21 10:30  六七十三  阅读(256)  评论(0编辑  收藏  举报