Transfer string content to a file in remote machine using java

只谈情不闲聊 提交于 2019-12-06 08:05:54

If I understand your problem correctly, you'd like to be able to copy some string data to a remote machine without reading a file locally. If you look at the javadoc, put accepts InputStream. So you do:

InputStream stream = new ByteArrayInputStream(content.getBytes());
sftpChannel.put(stream, "name.txt");

Note that you can also put(String dst) where you can write to the OutputStream that is returned. But I didn't show that.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!