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

问题描述 投票:1回答:1

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

FTPSClient ftps =new FTPSClient();

然后连接到服务器使用带有ip地址的connect()方法。

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

在每一步之后,我将使用检查回复代码。

ftps.getReplyCode();

在下面的代码中,我知道username = system username password =要登录的密码

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

我不知道为远程和本地提供什么价值。请帮助我提供给他们的价值观以及内部发生的事情。

java ftps
1个回答
1
投票
    // 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

© www.soinside.com 2019 - 2024. All rights reserved.