title: How to get filtered list of files from SFTP server using SSHJ
body: <p>I am trying to get a filtered list of files from a SFTP server using <strong>SSHJ</strong>. It works fine without filter but I am not getting any example of filter.</p>
  <p>I am using list files like</p>
  <pre><code>            Map&lt;String, String&gt; map = new HashMap();
              map.put(&quot;ext&quot;, &quot;*.txt&quot;);
              RemoteResourceFilter filter = null;
              PathComponents path = new PathComponents(null, null, null).;
              FileAttributes attr = new FileAttributes.Builder().withExtended(map).build();
              
              RemoteResourceInfo rri = new RemoteResourceInfo(path, attr);
              filter.accept(rri);
  
              List&lt;RemoteResourceInfo&gt; rs =  sftp.ls(&quot;/sftpuser1&quot;, filter);
              System.out.println(rs.size());
              for(int i=0; i&lt;rs.size(); i++) {
                  System.out.println(rs.get(i).getName().toString());
              }
  </code></pre>
  <p>Please could you help me with an example of retrieving files with filter?</p>