gpt4 book ai didi

通过 ftps 连接 alfresco 的 Java 代码

转载 作者:行者123 更新时间:2023-12-01 12:37:45 30 4
gpt4 key购买 nike

您好,我正在尝试通过 FTP 连接我们的露天场所,但我收到错误 Unknownhostexception

我的代码如下

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);

关于通过 ftps 连接 alfresco 的 Java 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25424782/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com