【发布时间】:2016-03-28 16:43:21
【问题描述】:
一旦程序使用 FTPClient connect() 方法连接到服务器,我如何发送字符串并将它们附加到位于远程计算机中的文件?
我已阅读其他帖子,但他们不使用 Apache Commons Net 库。
【问题讨论】:
标签: java ftp remote-access apache-commons
一旦程序使用 FTPClient connect() 方法连接到服务器,我如何发送字符串并将它们附加到位于远程计算机中的文件?
我已阅读其他帖子,但他们不使用 Apache Commons Net 库。
【问题讨论】:
标签: java ftp remote-access apache-commons
From the docs(您确实检查了文档,对吗?),您需要 FTP 客户端上的 appendFile() 方法。
类似
String text = "...."
String remoteFileName = "..."
FTPClient ftp = ... // Already connected
try (ByteArrayInputStream local = new ByteArrayInputStream(text.toBytes("UTF-8"))) {
ftp.appendFile(remoteFilename, local);
} catch (IOException ex) {
throw new RuntimeException("Uh-oh", ex);
}
【讨论】: