use of com.sshtools.j2ssh.sftp.SftpFile in project iaf by ibissource.
the class FtpSession method ls.
public List ls(String remoteDirectory, boolean filesOnly, boolean closeAfterSend) throws Exception {
openClient(remoteDirectory);
try {
if (ftpType == SFTP) {
List result = new LinkedList();
List listOfSftpFiles = sftpClient.ls();
for (Iterator sftpFileIt = listOfSftpFiles.iterator(); sftpFileIt.hasNext(); ) {
SftpFile file = (SftpFile) sftpFileIt.next();
String filename = file.getFilename();
if (filesOnly || (!file.isDirectory())) {
if (!filename.startsWith(".")) {
result.add(filename);
}
}
}
return result;
}
return FileUtils.getListFromNames(ftpClient.listNames());
} finally {
if (closeAfterSend) {
closeClient();
}
}
}
Aggregations