Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to download file from another system using FTP in JAVA ?

843790Nov 21 2008 — edited Nov 24 2008
Hi,

how to download a file from remote system using FTP in java ?

I wrote a code in java using URL class. But it didn't work.
                   try {
                      System.out.println ("FTP prg");
                       String FTP_Address = "ftp://bruvo:bruvo123@192.114.1.93/home/bruvo/test.txt;type=i";
			URL url = new URL(FTP_Address);
 			URLConnection con = url.openConnection();
			BufferedInputStream in = new BufferedInputStream(con.getInputStream());
			FileOutputStream out = new FileOutputStream("/home/sjayaram/Store/test.txt");
			int i = 0;
			byte[] bytesIn = new byte[1024];
		       while ((i = in.read(bytesIn)) >= 0) 
                        {
			out.write(bytesIn, 0, i);
			}
			out.close();
                       }
In " ftp://bruvo:bruvo123@192.114.1.93/home/bruvo/test.txt;type=i " string,

bruvo is user name, bruvo123 is password and 192.114.1.93 is the remote system IP.

But, it doesn't works.

Any one have idea?.


Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2008
Added on Nov 21 2008
12 comments
494 views