0
votes

Is there a way to do asynchronous sftp file transfer with Jsch without having to manage your own threads?

I see there is a SftpProgressMonitor to monitor the progress but it just provides a callback.

I'm looking for something similar to Java's AsynchronousFileChannel write method:

public abstract Future write(ByteBuffer src, long position)

Which library provides async sftp transfer?

1
There's no support for asynchronous transfers in JSch. - Martin Prikryl
@MartinPrikryl Neither there seems to be such support in any of the other free Java sftp libraries that I investigated. Sad. - Roland

1 Answers

1
votes

I solved the problem performing the transfer asynchronously using CompletableFuture(take a look at runAsync and supplyAsync methods).

The class also offers methods to combine or chain multiple futures together with methods like: CompletableFuture.allOf, CompletableFuture.thenCompose, etc...