在 Java 1.4 中,我正在尝试连接到 URL,但由于我想配置超时,所以我使用 Apache 的 httpclient 而不是老式的 URLConnection.openConnection();
所以我有以下内容:
HttpConnection conn = null;
SimpleHttpConnectionManager httpMgr = new SimpleHttpConnectionManager(true);
HostConfiguration hostConf = new HostConfiguration();
hostConf.setHost(new HttpHost("http://www.google.com"));
conn = httpMgr.getConnectionWithTimeout(hostConf, 30);
conn.open();
但似乎每次我尝试打开连接时,我都会得到一个 java.net.UnknownHostException: http://www.google.com,甚至是 google.com。
我做错什么了吗..?