Java - download from SFTP directly to memory without ever writing to file

寵の児 提交于 2019-12-08 04:50:51

问题


I have been researching this for the past couple days but cannot seem to find an example or documentation for anything that reads from an SFTP server and writes the contents to memory and not a file. It got me thinking if this is even possible. I was hoping to write the file downloaded from the SFTP stream to a byte array in memory and then work with that while the byte array was in memory. Is this possible?


回答1:


The most common Java SFTP library, the JSch, allows this.

Use one of its overloads of the ChannelSftp.get method that return the InputStream.

The basic one is:

public InputStream get(String src)


来源:https://stackoverflow.com/questions/32900090/java-download-from-sftp-directly-to-memory-without-ever-writing-to-file

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