Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File download from Unix server with password  RSS feed

 
harry flower
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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 ]
 
Rashid Mayes
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!