title: Apache Commons FTPClient.listFiles
body: <p>I am using <a href="http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html" rel="noreferrer"><code>org.apache.commons.net.ftp.FTPClient</code></a> in one of my applications to work with a FTP server. I am able to <code>connect</code>, <code>login</code>, <code>pwd</code> and <code>cwd</code>. However, when I try to <code>list</code> the files it doesn't return the list of files in that directory, where I know for sure that there are files. I am using the method <a href="http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html#listFiles()" rel="noreferrer"><code>FTPFile[] listFiles()</code></a>, it returns an empty array of <code>FTPFile</code>.</p>
  
  <p>Please find below the code snippet where I am trying this:</p>
  
  <pre><code>        String hostname = properties.getProperty("FTP_SERVER");
          String user = properties.getProperty("FTP_USER");
          String passwd = properties.getProperty("FTP_PASSWD");
          FTPClient client = new FTPClient();
          client.connect(hostname);
          client.login(user, passwd);
          String reply = client.getStatus();
          System.out.println(reply);
          client.enterRemotePassiveMode();
          client.changeWorkingDirectory("/uploads");
          FTPFile[] files = client.listFiles();
          System.out.println(files.length);
          for (FTPFile file : files) {
              System.out.println(file.getName());
          }
  
          String[] fileNames = client.listNames();
          if (fileNames != null) {
              for (String file : fileNames) {
                  System.out.println(file);
              }
          }
          client.disconnect();
  </code></pre>