URL url = new URL(\"ftp://user:pass@ftp.example.com/thefolder/\");
URLConnection connection = url.openConnection();
...
// List files in folder...
You could use Apache commons FTPClient
This would allow you to call listFiles with...
public static void main(String[] args) throws IOException {
FTPClient client = new FTPClient();
client.connect("c64.rulez.org");
client.enterLocalPassiveMode();
client.login("anonymous", "");
FTPFile[] files = client.listFiles("/pub");
for (FTPFile file : files) {
System.out.println(file.getName());
}