Hi folks, I want the list of files of a particular directory which is present in sftp server or ftp server.I written following code to do that but it is not working for me.
FTPClient client = new FTPClient();
try {
client.connect("ftp.secureftp-test.com ");
client.login("test", "test");
String[] names = client.listNames();
for (String name : names) {
System.out.println("Name = " + name);
}
FTPFile[] ftpFiles = client.listFiles();
for (FTPFile ftpFile : ftpFiles) {
// Check if FTPFile is a regular file
if (ftpFile.getType() == FTPFile.FILE_TYPE) {
System.out.println("FTPFile: " + ftpFile.getName() + "; " + FileUtils.byteCountToDisplaySize(ftpFile.getSize()));
}
}
client.logout();
client.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
I replace the jar of jsse but now above code is not giving any output.It does not returning any file name.
So anybody knows how to get the list of all files from ftp or sftp server using java and only opensource libraries.