Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's methods in the <a href="https://epaul.github.io/jsch-documentation/javadoc/com/jcraft/jsch/ChannelSftp.html" rel="nofollow noreferrer">com.jcraft.jsch.ChannelSftp</a> that you use to pass in a callback. Look at the </p> <pre><code>void get(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor) </code></pre> <p>methods and <a href="https://epaul.github.io/jsch-documentation/javadoc/com/jcraft/jsch/SftpProgressMonitor.html" rel="nofollow noreferrer">com.jcraft.jsch.SftpProgressMonitor</a> interface. At the bottom of this <a href="http://www.jcraft.com/jsch/examples/Sftp.java" rel="nofollow noreferrer">Example Code</a> (it's kind of messy), you'll find an implementation of SftpProgressMonitor that uses its callback methods <code>count(long)</code> and <code>end()</code> to manipulate a <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/ProgressMonitor.html" rel="nofollow noreferrer">javax.swing.ProgressMonitor</a>.</p> <p><code>count(long)</code> gets called periodically when there's some bytes that have been transfered, and <code>end()</code> gets called when the transfer has ended. So a really simple imeplementation of SftpProgressMonitor could be:</p> <pre><code>public class SystemOutProgressMonitor implements SftpProgressMonitor { public SystemOutProgressMonitor() {;} public void init(int op, java.lang.String src, java.lang.String dest, long max) { System.out.println("STARTING: " + op + " " + src + " -&gt; " + dest + " total: " + max); } public boolean count(long bytes) { for(int x=0; x &lt; bytes; x++) { System.out.print("#"); } return(true); } public void end() { System.out.println("\nFINISHED!"); } } </code></pre> <p>I'd then create an instance of that and pass it to <code>get()</code></p> <pre><code>sftpChannel.get(sourcePath, destPath, new SystemOutProgressMonitor()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload