FTP with Java

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.*;importcom.oroinc.net.ftp.*;public final classFTP {  public static final voidmain(String[] args) {    FTPClientclient;    client = new FTPClient();try {      client.connect("ftp.javasoft.com");if(!FTPReply.isPositiveCompletion(client.getReplyCode())) {client.disconnect();System.err.println("FTP server refusedconnection.");   return;      }client.login("anonymous","[email protected]");client.setFileType(com.oroinc.net.ftp.FTP.BINARY_FILE_TYPE);client.retrieveFile("docs/source_license.pdf",           newFileOutputStream("source_license.pdf"));client.quit();client.disconnect();    }catch(IOException e) {e.printStackTrace();    }  }}

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular