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?
The most common Java SFTP library, the JSch, allows this.
Use one of its overloads of the ChannelSftp.get
method that return the InputStream
or accept OutputStream
.
The basic one is:
public InputStream get(String src)