• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Download file from FTP using java client

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do basic FTP using the Standard API:
 
gopinathang nathan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Can't get jakarta commons to work true proxy and nat

// Mathias
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic