views:

71

answers:

2

Greetings all,

I am trying to download 'gz' file using URL class .Code snippet is as:

URL url = new URL("ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb132l.ent.gz");
InputStream conn = new GZIPInputStream(url.openStream());

But it throws the error:

Exception in thread "main" java.net.UnknownHostException: ftp.wwpdb.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:525) at java.net.Socket.connect(Socket.java:475)

What could be the issue?

+1  A: 

I think you are missing the FTP username/password
You can use some FTP client library to download from FTP.
http://www.ajaxapp.com/2009/02/21/a-simple-java-ftp-connection-file-download-and-upload/

Padmarag
hmm.you can directily download the file in browserthe link ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb132l.ent.gz
umanga
+3  A: 

I copy-pasted your code and it downloads the file on my machine. You probably have a network problem.

Petar Minchev
what? hmm..I can download the file using browser? only this happens in Java ?
umanga
and are you java network settings the same as the browser settings?
n002213f
I dont use proxies ,if you were refering to network settings
umanga
Can you try this: InetAddress.getLocalHost() and tell if you get UnknownHostException.
Petar Minchev
hi Peter, no there no errors for InetAddress.getLocalHost()it gives "umanga/192.168.2.33"
umanga
I know this sounds crazy, but if you are using TCP/IPv6, could you try removing the support for it from your machine and try again.
Petar Minchev
I am sorry, I was using 16bit JRE in Eclipse. eventhough I'm in 64bit linux.I changed to 64bit and now everything is fine..thanks
umanga