Monday, June 22, 2009

Java FTP Tips

The simplest way to access an FTP site is to use a URL string. You may be able to do something like this:

URL url =
new URL(";type=i");
URLConnection con = url.openConnection();
BufferedInputStream in =
new BufferedInputStream(con.getInputStream());
FileOutputStream out =
new FileOutputStream("C:\\");

int i = 0;
byte[] bytesIn = new byte[1024];
while ((i = >= 0) {
out.write(bytesIn, 0, i);

This method can work if:

* the site supports it
* you know exactly what file you need and where it is
* you don't have to do anything other than just download a file

Author : Anuj Patel
LinkedIn :
Blog :

No comments:

Post a Comment