Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Daniel Savarese
Language: Java, Web
Expertise: Intermediate
Aug 31, 1998



Application Security Testing: An Integral Part of DevOps

FTP with Java

Normally, from within a Java applet you can create a java.net.URL instance using the "ftp://" protocol handler. But you may need a third-party library to access FTP from a Java application. There is a package called com.sun.net.ftp that you can use, but it is non-standard and not guaranteed to be available on every platform. By using a third-party package, you can ensure your program will work everywhere by distributing the classes with your program. One package that provides FTP functions, as well as others, is called NetComponents, available from http://www.oroinc.com. It contains a package called com.oroinc.net.ftp and a class called FTPClient with which you can access ftp from a program. I've included a simple example of how to fetch a file from an FTP server and write it to the local file system:
import java.io.*;import
com.oroinc.net.ftp.*;public final class
FTP {  public static final void
main(String[] args) {    FTPClient
client;    client = new FTPClient();
try {      client.connect("ftp.javasoft.com");
client.getReplyCode())) {
System.err.println("FTP server refused
connection.");   return;      }
source_license.pdf",           new
client.disconnect();    }
catch(IOException e) {
e.printStackTrace();    }  }}
Submit a Tip Browse "Application Design" Tips Browse All Tips
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date