private Vector<LsEntry> listEntries(final ChannelSftp channelSftp, final String path) throws SftpException { final Vector<LsEntry> vector = new Vector<LsEntry>(); LsEntrySelector selector = new LsEntrySelector() { public int select(LsEntry entry) { final String filename = entry.getFilename(); if (filename.equals(".") || filename.equals("..")) { return CONTINUE; } if (entry.getAttrs().isLink()) { vector.addElement(entry); } else if (entry.getAttrs().isDir()) { if (keepDirectory(filename)) { vector.addElement(entry); } } else { if (keepFile(filename)) { vector.addElement(entry); } } return CONTINUE; } }; channelSftp.ls(path, selector); return vector; }