@ Override public long copyFileTo ( OutputStream dest , long skip ) throws FileNotFoundException , CopyFileToException { ChannelSftp sftp ; Progress monitor ; try { sftp = alloc ( ) ; monitor = new Progress ( ) ; try { sftp . get ( escape ( slashPath ) , dest , monitor , ChannelSftp . RESUME , skip ) ; } finally { free ( sftp ) ; } return Math . max ( 0 , monitor . sum - skip ) ; } catch ( SftpException e ) { if ( e . id == 2 || e . id == 4 ) { throw new FileNotFoundException ( this ) ; } throw new CopyFileToException ( this , e ) ; } catch ( JSchException e ) { throw new CopyFileToException ( this , e ) ; } }
This is the core function to read an ssh node . Does not close dest .