commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Youssef Eldakar <youssef.elda...@bibalex.org>
Subject retrieveFile Hangs After Few Hundred Calls
Date Wed, 13 Jun 2007 13:18:05 GMT
I am using FTPClient to download hundreds of files. The source code is
below. Each time I run the program, a couple hundred files are retrieved
before the retrieveFile method hangs at a random file and never returns.
At that point, netstat still shows an ESTABLISHED connection with the
server. I am wondering if someone could offer a suggestion on how I
could debug this further. I am running JDK 1.5.0_11 on Debian Etch.

--

import java.io.*;
import java.lang.*;

import org.apache.commons.net.ftp.*;

public class ftpget {
  public static void main(String[] args) {
    try {
      FTPClient ftp = new FTPClient();

      ftp.connect(...);
      ftp.login(...);

      ftp.setFileType(ftp.IMAGE_FILE_TYPE);

      ftp.changeWorkingDirectory(...);

      FTPFile[] files = ftp.listFiles();

      for(int i = 0; i < files.length; i++) {
        if(files[i].isFile()) {
          FileOutputStream os = new FileOutputStream(files[i].getName());

          ftp.retrieveFile(files[i].getName(), os);

          os.close();
        }
      }

      ftp.logout();
      ftp.disconnect();
    } catch(Exception e) {
      ...
    }
  }
}

--

Youssef Eldakar
Bibliotheca Alexandrina

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message