如何使用 Apache Commons Net 写入远程文件?
How can I write to a remote file using Apache Commons Net?
使用 FTPClient connect() 方法将程序连接到服务器后,如何发送字符串并将它们附加到位于远程计算机中的文件?
我读过其他帖子,但他们没有使用 Apache Commons Net 库。
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);
}
使用 FTPClient connect() 方法将程序连接到服务器后,如何发送字符串并将它们附加到位于远程计算机中的文件?
我读过其他帖子,但他们没有使用 Apache Commons Net 库。
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);
}