0
votes

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?

2
it works fine for me. which Java version are you using?Bozho
I download the file using Browser.But not in java?Ashika Umanga Umagiliya
I use java version "1.6.0_15" 64 bit (build 1.6.0_15-b03)Ashika Umanga Umagiliya
I am sorry, I was using 16bit JRE eventhough I'm in 64bit linux..Ashika Umanga Umagiliya

2 Answers

4
votes

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

1
votes

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/