sshj
sshj copied to clipboard
How to read from the remote file into a Stream ?
trafficstars
Can anyone please help in reading a remote file into a Stream? I understand that I need to use something similar to this
sftpClient.get("/home/sftp/file1", new InMemoryDestFile() {
@Override
public OutputStream getOutputStream() throws IOException {
return null;
});
but any process on how exactly to do this would be helpful. Thanks in advance
To obtain an InputStream from a RemoteFile, you can do this:
RemoteFile f = sftpClient.getSFTPEngine().open("/home/sftp/file1");
InputStream is = f.new RemoteFileInputStream(0);
I also have a question, how do I upload a file stream directly to a remote path without creating a new file locally to upload