Java FTP multi file transfer

Asked By 0 points N/A Posted on -
qa-featured

Hello Friends,

I heard that Java FTP multi file transfer will be very much effective and will run at high speed, Can anyone provide me the Java coding for FTP multi file transfer.

Please Help,

Angela D Sloan

SHARE
Answered By 0 points N/A #198801

Java FTP multi file transfer

qa-featured

There are four options to transfer FTP files in java, and one of them gives the opportunity of transferring multi files, named, Jakarta Net Classes. It is well tested and free to use, is more feature-rich than other classes, so Jakarta Commons is a good bet. The code for using this is:

 

FTPClient ftp = new FTPClient();

ftp.connect("ftp.example.com");

ftp.login("admin", "secret");

ftp.setFileType(FTPClient.BINARY_FILE_TYPE);

 

for(File file : files) {

    InputStream in = new FileInputStream(file);

    ftp.storeFile(file.getName(), in);

    in.close();

}

 

ftp.disconnect();

 

 

Login/Register to Answer

Related Questions