• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Download file from FTP using java client

 
gopinathang nathan
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

is that possible to download a file from FTP using java client. i have tried access servlet via java client. i am not sure about FTP site, any insight on this highly appreciated!

Thanks
Gopi
 
gopinathang nathan
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this doc helped me to connect to ftp and download the files.
http://www.nsftools.com/tips/JavaFtp.htm

but not sure how to browser ftp site. any insight on this appreciated!

Thanks
Gopi
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jakarta Commons Net project includes an ftp client library, which makes it easy to include ftp capabilities into your application.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do basic FTP using the Standard API:
 
gopinathang nathan
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe and Ulf, as you mentioned, i could directly refer the file and download. Is it possible to log into ftp site and based on the folder name provided, can i browse and get the files in that folder?

For excample
ftp://user ass@ftpsite.com/gopi/a.txt

i will log in using the URL - ftp://user ass@ftpsite.com. will be possible to browse folders under the root and get 'a.txt'?

Thanks again
[ November 14, 2006: Message edited by: gopinathang nathan ]
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use the Jakarta Commons Net package Ulf mentioned, there's methods in the FTP client object to list the contents of a directory.
With the URL-based method, you simply request the directory rather than a particular file.
The convenient thing about the Net package is that they do the parsing of the directory information for you. With the URL-based method you get a text listing of the directory and you have to parse out the file names.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Can't get jakarta commons to work true proxy and nat

// Mathias
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the Commons Net FAQ?

Q: Does FTPClient support FTP connections through an FTP proxy server?

A: Paul Buchanan answers this question here: [WWW] http://marc.theaimsgroup.com/?l=jakarta-commons-user&m=107877944806547&w=2

The summary is:

Since the Net project uses java.net.Socket under the covers, you have to set up the Socket settings. If the proxy you are using is a SOCKS4 or SOCKS5 proxy, you can set the following System Properties:

System.getProperties().put( "socksProxyPort", "1080");
System.getProperties().put( "socksProxyHost" ,"proxy.host.address");

From what I can tell, 1080 is the default port for SOCKS proxies. The following site documents many of the networking System Properties available:

http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

I have read this link but our firewall, nat etc is on a sun solaris with an proxy server that does not support socks proxy. Only http and ftp
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic