Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.2k views
in Java FTP by (820 points)
Hi

I am wanting to list the files and folders in my directory in a specific order. i.e. I need all the folders to be listed first in alphabetical order followed by the files in alphabetical order.

Currently I have the code below, but that just displays everything together in alphabetical order

String[] files = ftp.dir(".");        
for(int i = 0; i < files.length; i++)
{
   remoteFiles.add(files[i]);
}

2 Answers

0 votes
by
Try using one of the dirdetails() methods. They return FTPFile objects which you can use to find out if directory entries are files or directories.

- Hans (EDT)
0 votes
by (820 points)
Thanks for the post, problem solved. I should have really read the documentation a bit closer.

Categories

...