0

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?

4
  • 1
    it works fine for me. which Java version are you using? Commented Feb 18, 2010 at 7:19
  • I download the file using Browser.But not in java? Commented Feb 18, 2010 at 7:19
  • I use java version "1.6.0_15" 64 bit (build 1.6.0_15-b03) Commented Feb 18, 2010 at 7:20
  • I am sorry, I was using 16bit JRE eventhough I'm in 64bit linux.. Commented Feb 18, 2010 at 8:51

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

6 Comments

what? hmm..I can download the file using browser? only this happens in Java ?
and are you java network settings the same as the browser settings?
Can you try this: InetAddress.getLocalHost() and tell if you get UnknownHostException.
hi Peter, no there no errors for InetAddress.getLocalHost() it gives "umanga/192.168.2.33"
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.
|
1

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/

1 Comment

hmm.you can directily download the file in browser the link ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb132l.ent.gz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.