gpt4 book ai didi

java - FTPSClient,为远程和本地提供什么值

转载 作者:行者123 更新时间:2023-11-30 05:41:45 26 4
gpt4 key购买 nike

我是 FTPSClient 新手,我尝试连接到在我的笔记本电脑中创建的 FTPS。我不知道一些方法的工作原理及其参数的含义。例如,在我的代码中,我创建了一个 FTPSClient,如下所示:

FTPSClient ftps =new FTPSClient();

然后使用 connect() 方法和 IP 地址连接到服务器。

ftps.connect("172.xx.xx.xxx");

每一步之后我都会使用检查回复代码。

ftps.getReplyCode();

在下面的代码中我知道用户名 = 系统用户名密码 = 登录密码

ftps.login(username, password);

在我的系统中的 Internet 信息服务(IIS)中。使用 ssl 创建一个 ftp 服务器并提供以下目录进行共享。

C:\Users\karan-pt2843\Desktop\FTPS

想要将以下目录中的文件发送到服务器。

D:\sam.txt

现在我想将文件存储在服务器中给定的上述目录中,我尝试使用

remote="";
local="";
InputStream input;
input = new FileInputStream(local);
ftps.storeFile(remote, input);
input.close();

我不知道应该为远程和本地赋予什么值(value)。请帮助我了解给予他们的值(value)观以及内部发生的情况。

最佳答案

    // Use passive mode as default because most of us are
// behind firewalls these days.
ftps.enterLocalPassiveMode();
...
String remote = "samFromClient.txt"; //Place on FTP
String input = "D:/sam.txt" //Place on your Client
//Your FTP reads from the inputstream and store the file on remote-path
InputStream input = new InputStream(new FileInputStream(input));
ftps.storeFile(remote, input);
input.close();
ftps.logout();
...

取自:Apache example

关于java - FTPSClient,为远程和本地提供什么值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55509370/

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