将文件传输到FTP的Java Commons Net问题。没有错误,但没有传输。

huangapple 未分类评论58阅读模式
标题翻译

Transfer file to FTP java commons.net problem. No error, but no transfer

问题

我在传输文件到我的FTP时遇到了一些问题。使用这段代码,我没有收到任何错误,但文件也没有被传到我的FTP服务器上。希望一些经验丰富的用户能指点我正确的方向。

FTPClient client = new FTPClient();
FileInputStream picture = null;

try {
    client.connect("地址", 端口);
    client.login("用户", "密码");
    client.changeWorkingDirectory("/htdocs/javaprojekt");

    client.setFileType(FTP.BINARY_FILE_TYPE);

    String filename = "/Users/sicknk/Documents/Java Projekt/fyeah.jpg";
    picture = new FileInputStream(filename);

    client.storeFile(filename, picture);
    client.logout();

} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        if (picture != null) {
            picture.close();
        }
        client.disconnect();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
英文翻译

I'm having some trouble with transferring files to my ftp.
with this code i get no errors, but I also don't get a file to my ftp server. I hope some more experienced users can point me to the right direction.

    FTPClient client = new FTPClient();
    FileInputStream picture = null;

    try {
        client.connect("adress" ,port);
        client.login("user", "password");
        client.changeWorkingDirectory("/htdocs/javaprojekt");

        client.setFileType(FTP.BINARY_FILE_TYPE);

        String filename = "/Users/sicknk/Documents/Java Projekt/fyeah.jpg";
        picture = new FileInputStream(filename);

        client.storeFile(filename, picture);
        client.logout();

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (picture != null) {
                picture.close();
            }
            client.disconnect();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

huangapple
  • 本文由 发表于 2020年1月30日 19:53:51
  • 转载请务必保留本文链接:https://java.coder-hub.com/59985488.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定