Download FTP File with


How to download a FTP file with program? I know the file path on the anonymous server.



If you know the file path on an anonymous FTP server, you can use the following command to download the file from the FTP server:

java -a -A -b examples.ftp.FTPClientExample host path file

   -a - Use active mode for data connections to avoid firewall settings
   -A - Use anonymous login
   -b - Use binary mode to download the file
   host - Host name or IP address of the FTP server
   path - Path name of the download file on the FTP server
   file - File name to save the downloaded file

Here is an example of running program to download the / file from the FTP server:

   -cp .;C:\local\commons-net-3.5\commons-net-3.5.jar
   examples.ftp.FTPClientExample -a -A -b

220 Welcome to the UofU School of Computing FTP Mirror
Connected to on 21
USER *******
331 Please specify the password.
PASS *******
230 Login successful.
215 UNIX Type: L8
Remote system is UNIX Type: L8
200 Switching to Binary mode.
PORT 192,168,1,7,239,1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 
   / (710625 bytes).
226 Transfer complete.
200 NOOP ok.
221 Goodbye.


Using commons-net.jar in Java Programs

⇒⇒FAQ for Apache commons-net.jar

2017-05-05, 645👍, 0💬