Search code examples
javaftpapache-commons-net

Listing subfolders recursivelly on FTP server


My problem is to get the paths of all files on the FTP server in Java. I want to be able to make List<String> of the paths of all files on on the server. I need this, to be able to determine, if a file exists on the server that is not on a local computer and vice versa. How do I get a list of the paths for each file on the server?

like:

... 
List<String> templist = new LinkedList<>();
String strings[] = someMethod()
for(int i = 0; i < strings.length; i++){
    templist.add(strings[i]);
} 
...

That when .forEach(System.out::println()) is run over the templist displays something like:

xxx.txt 
foo/bar.txt
foo/b/y.txt

I'm using the Apache Commons FTP library in Java.

Thanks for the help!


Solution