How to stream the ls method in ChannelSftp

azaza
2012-02-15
2013-05-28
  • azaza
    azaza
    2012-02-15

    Hi,

    I use JSCH API and i need to stream the ls method, so to implement this i need to return an Iterator.

    Current implementation

    Vector< ? > vFiles = m_cSftpChannel.ls( strRemotePath );
    for ( int i = 0; i < vFiles.size(); i++ )
    { 
       ...
    }
    

    Needed implementation

    int quantityRequested = 100;
    Iterator< ? > itRemoteFiles = m_cSftpChannel.ListFiles( sDirectory );
    while( itRemoteFiles.hasNext() )
    {
       // Returns an array of at most quantityRequested 
       // objects starting at this object's internal iterator's current position.
        Object[] alLsEntry = itRemoteFiles.next( quantityRequested );
       ...
    }
    

    I have started the implementation of this feature, if you have any suggestion or an implementation of this feature please do not hesitate to contact me.

    Regards.