开发者

Java URL problem?

开发者 https://www.devze.com 2022-12-20 07:42 出处:网络
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\");

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?


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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消