Search in sources :

Example 1 with SftpFile

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();
        }
    }
}
Also used : SftpFile(com.sshtools.j2ssh.sftp.SftpFile) Iterator(java.util.Iterator) ParameterList(nl.nn.adapterframework.parameters.ParameterList) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

SftpFile (com.sshtools.j2ssh.sftp.SftpFile)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ParameterList (nl.nn.adapterframework.parameters.ParameterList)1