September 29, 2009

Java FTP Example

« Java Runtime Inspection - Pax Reflector | Main | Hibernate Spring Tutorial »

The Apache Commons Net project offers you an API for FTP access. Based on this API you can download, upload or traverse the directory tree of your FTP account.

The following steps are required to use the FTP API:

<dependency>
    <groupId>commons-net</groupId>
    <artifactId>commons-net</artifactId>
    <version>2.0</version>
</dependency>
FTPClient f = new FTPClient();
f.connect("ftp.developers-blog.org");
f.login("username", "password");
FTPFile[] files = f.listFiles("/");
for (FTPFile file:files) {
  System.out.println("" + file.getName());
}
Regards
Rafael Sobek

Technorati Tags:

Posted by rafael.sobek at 6:37 AM in Java

 

[Trackback URL for this entry]

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
 
test