通过ftps连接连接alfresco的Java代码

时间:2014-08-22 09:20:10

标签: java alfresco ftp-client ftps

当我尝试通过SFTP连接我们的露天时,它无法连接露天。它挂起了资源管理器,并且记录器文件中也没有错误。

public void FTPTest()throws SocketException, IOException, NoSuchAlgorithmException
{

    FTPSClient ftp = new FTPSClient("SSL");
    System.out.println("1");
    ftp.connect("172.17.178.144",2121); // or "localhost" in your case
    System.out.println("2"+ftp.getReplyString());

    System.out.println("login: "+ftp.login("admin", "admin"));
    System.out.println("3"+ ftp.getReplyString());
    ftp.changeWorkingDirectory("/alfresco");
    // 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();

}

我只在控制台输出了输出  1 执行ftp.connect(“172.17.178.144”,2121);这个代码系统将在我们的控制台中挂起没有错误

我可以使用Filezila FTP客户端软件通过SFTP连接到我的Alfresco。任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

如果我没弄错的话,那么Alfresco选择了FTPS。

请尝试使用以下代码:http://alvinalexander.com/java/jwarehouse/commons-net-2.2/src/main/java/examples/ftp/FTPSExample.java.shtml

相关问题