title: how to get list of file from ftp server if server is very slow or there are more clients are there in java
body: <p>I have to get the list of files or folder present in ftp  server .I have tried the following  code but I do not get the list. If I am running the same code I am getting list of file if I am making my local system as server but when I apply the same code then I am sucessfully logged in and list method of <code>FTPClient</code> class is working but <code>listFiles()</code>,<code>listNames()</code> are not working . </p>
  
  <pre><code>import java.io.IOException;
  import java.net.SocketException;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import org.apache.commons.net.ftp.FTPClient;
  import org.apache.commons.net.ftp.FTPClient;
  import org.apache.commons.net.ftp.FTPFile;
  import org.apache.commons.io.FileUtils;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Calendar;
  /**
   *
   * @author admin
   */
  public class ListFileOfServerCheck {
  
      public static void main(String args[]) throws SocketException, IOException{
  
      FTPClient client = new FTPClient();
      ArrayList dirList=new ArrayList();
  
     client.connect("myserver");
     client.login("vishal", "vishal");
      if(client.isConnected())
          System.out.println("connected");
      int i=0;
      System.out.println("number of files on server="+client.list());
      String[] names = null;
      int itration=1;
      while(names==null){
         System.out.println(itration +"th itration");
         names = client.listNames();
         itration++;
      }
      client.logout();
      client.disconnect();
  
      }
  
  }
  </code></pre>