1

I am currently using JSch to access some files using SFTP and I also need to perform some changes in each file once it is on the remote server.

I am able to access and read the files using ChannelSftp but I would like to create a temporary file while in this remote directory as well. I cannot see a way to do this. I have the ability to make directories and remove files, but not create an empty file? Is this something you can do using ChannelSftp?

1 Answer 1

4

You can put an arbitrary file from an InputStream: put(InputStream src, String dst). You can upload an empty file with that as follows:

put( new ByteArrayInputStream( "".getBytes() ), "tempfile");
1
  • 1
    thank you this has been torturing me for like a day and a half!
    – caro
    Mar 1, 2016 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.