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();
}
}
}