用于通过ftps连接alfresco的Java代码
嗨,我正在尝试通过FTP连接我们的户外,但我得到了未知错误hostexception 我的代码如下用于通过ftps连接alfresco的Java代码,java,ftp,alfresco,Java,Ftp,Alfresco,嗨,我正在尝试通过FTP连接我们的户外,但我得到了未知错误hostexception 我的代码如下 public void FTPTest()throws SocketException, IOException { FTPClient ftp = new FTPClient(); System.out.println("1"); ftp.connect("172.17.178.144:2121"); // or "localhost" in your case
public void FTPTest()throws SocketException, IOException
{
FTPClient ftp = new FTPClient();
System.out.println("1");
ftp.connect("172.17.178.144:2121"); // or "localhost" in your case
System.out.println("2");
System.out.println("login: "+ftp.login("admin", "admin"));
System.out.println("3");
ftp.changeWorkingDirectory("folder/subfolder/");
// list the files of the current directory
FTPFile[] files = ftp.listFiles();
System.out.println("Listed "+files.length+" files.");
for(FTPFile file : files) {
System.out.println(file.getName());
}
// lets pretend there is a JPEG image in the present folder that we want to copy to the desktop (on a windows machine)
ftp.setFileType(FTPClient.BINARY_FILE_TYPE); // don't forget to change to binary mode! or you will have a scrambled image!
FileOutputStream br = new FileOutputStream("C:\\Documents and Settings\\casonkl\\Desktop\\my_downloaded_image_new_name.jpg");
ftp.retrieveFile("name_of_image_on_server.jpg", br);
ftp.disconnect();
}
我有以下错误
java.net.UnknownHostException:172.17.178.144:2121
您应该这样尝试,将端口设置为单独的参数
FTPClient ftp = new FTPClient();
ftp.connect("172.17.178.144","2121");
ftpClient.connect(server, port);
你能打172.17.178.144吗?FTP客户来自哪里?您确定不应该将端口作为第二个参数吗?谢谢您的回复,现在我可以将whwn passing ip和port作为两个参数连接起来,如ftp.connect172.17.178.1442121;但我无法通过它的发送登录,发送2220 FTP服务器就绪登录:false 3列出了0个文件。