问题
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