Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.zybnet;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.net.SocketException;
- import org.apache.commons.io.output.CountingOutputStream;
- import org.apache.commons.io.output.NullOutputStream;
- import org.apache.commons.net.ftp.FTPClient;
- public class FTP {
- public static void main(String[] args) throws SocketException, IOException {
- FTPClient client = new FTPClient();
- client.connect("ftp.mozilla.org");
- client.login("anonymous", "");
- client.enterLocalPassiveMode();
- OutputStream out = new CountingOutputStream(new NullOutputStream()) {
- @Override
- public void beforeWrite(int count) {
- super.beforeWrite(count);
- System.out.println("Downloaded " + getCount() + " bytes");
- }
- };
- for (String filename: new String[] {"MD5SUMS", "SHA1SUMS"})
- client.retrieveFile("pub/firefox/releases/15.0b4/" + filename, out);
- out.close();
- client.disconnect();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement