• 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

File download from Unix server with password

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am having some problem to get file from URL (of a unix server) with password.
I keep on getting this error: "FileNotFoundException"
However, if I enter the url in the Internet Explorer,
I am able to access the file.

My code is as follow:

...
BufferedInputStream input = null;
BufferedOutputStream output = null;

try {

String address = "ftp://username assword@myunixftpserver.domain.com/home/dir/myfile.zip";
URL url = new URL(address);
URLConnection conn = url.openConnection();

//I got the ERROR at this code below
input = new BufferedInputStream(conn.getInputStream());

...


What could be the possible problem?
Thanks in advance for your advise.

Best regards
[ September 10, 2007: Message edited by: harry flower ]
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Although I have not encountered this issue, I would suggest looking into the Apache FTPClient? or maybe JFtp?

They offer a more command-line like FTP conversation and you could test each step by (1) establishing the connection first, (2) performing authentication and (3) requesting the file resource.
 
harry flower
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I actually encountered this error: "500 Illegal PORT command, EPSV ALL in effect". What could be the problem? Thanks.
 
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
And your code is?
I did some googling for your error and it appears to be either caused by either using the get task instead of ftp or using active mode ftp instead of passive.
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by harry flower:
Now I actually encountered this error: "500 Illegal PORT command, EPSV ALL in effect". What could be the problem? Thanks.



http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html#URL(java.lang.String,%20java.lang.String,%20int,%20java.lang.String)

Have you looked at the API docs? Maybe you need to use the URl contrstuctor that accepts the port (21) and protocol (ftp)? I can't test it and I've never used URL(), but it might be worth a shot.
 
reply
    Bookmark Topic Watch Topic
  • New Topic