Closed:How To Download All Files In A Ftp Directory
1
0
Entering edit mode
13.8 years ago
User 4686 ▴ 220

Hi all, currently i can download only one file from the server, how do i download all the remaining files i want automatically using Java codes??

import java.io.*;

import java.net.URL;
import java.net.URLConnection;
import java.io.FileOutputStream;


public class ftp {

public static void main(String[] args) {

    try{

URL url =     new URL("ftp://ftp.wwpdb.org//pub//pdb//data//structures//all//pdb//pdb100d.ent.gz;type=d");
URLConnection con = url.openConnection();

BufferedInputStream in =     new BufferedInputStream(con.getInputStream());
FileOutputStream out =     new FileOutputStream("C:\\Users\\Royston\\Documents\\FTP downloads\\pdb100d.ent.gz");

int i = 0;
byte[] bytesIn = new byte[1024];

while ((i = in.read(bytesIn)) >= 0)
 {
out.write(bytesIn, 0, i);
 }
out.close();
in.close();
    } catch(Exception e)
        {
        e.printStackTrace();
        }    
    }   
}
download • 531 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 1605 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6