Thanks

-----Original Message-----
From: Guillaume Nodet [mailto:gno...@apache.org] 
Sent: November-02-15 3:56 PM
To: users@mina.apache.org
Subject: Re: Sftp client - large directory listing

You need to call  readDir(h) multiple times until it returns null which 
signifies that the whole directory has been read.

2015-10-15 20:20 GMT+02:00 Gabriel Kapitany <gkapit...@symcor.com>:

> Hi all,
>
>
>
> I’m using the SSH client library and trying to list a remote directory 
> containing large number of files +10,000.
>
>
>
> Something along this line:
>
> …..
>
> sftp = session.createSftpClient();
>
> …
>
> List<String> myList = *new* ArrayList<String>();
>
>        SftpClient.DirEntry[] dir = *null*;
>
>        *try* {
>
>               h = sftp.openDir(folder);
>
>               dir = sftp.readDir(h);
>
>
>
>
>
>        } *catch* (IOException e) {
>
>
>
>               *throw* *new* InterruptedException("Can't open directory: "
> + e);
>
>        }
>
>
>
>        *int* count = dir.length;
>
>
>
>
>
> I’m looking for files in the list with a particular extension 
> filexxxxxx.ext, for which I call sftp.get.
>
> The listing returns around 100 files unsorted, which doesn’t hold any 
> of the *.ext files, even though there are many of them on the remote folder.
> At this point my application gets stuck.
>
>
>
> I think this is due to the buffer size. How can I retrieve the whole 
> list?  Or, is there any other way to deal with the problem?
>
>
>
> Thanks,
>
> Gabriel
>
>
>
> CONFIDENTIALITY WARNING
> This communication, including any attachments, is for the exclusive 
> use of addressee and may contain proprietary and/or confidential 
> information. If you are not the intended recipient, any use, copying, 
> disclosure, dissemination or distribution is strictly prohibited. If 
> you are not the intended recipient, please notify the sender 
> immediately by return e-mail, delete this communication and destroy all 
> copies.
>
> AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ Ce message, ainsi que les 
> pièces qui y sont jointes, est destiné à l’usage exclusif de la 
> personne à laquelle il s’adresse et peut contenir de l’information 
> personnelle ou confidentielle. Si le lecteur de ce message n’en est 
> pas le destinataire, nous l’avisons par la présente que toute 
> diffusion, distribution, reproduction ou utilisation de son contenu 
> est strictement interdite. Veuillez avertir sur-le-champ l’expéditeur 
> par retour de courrier électronique et supprimez ce message ainsi que 
> toutes les pièces jointes.
>
>

Reply via email to