我尝试运行以下示例:
http://www.sonatype.com/books/mvnex-book/reference/customizing-sect-custom-exec.html
失败的代码基本上是:
String url = "http://weather.yahooapis.com/forecastrss?p=60202";
URLConnection conn = new URL(url).openConnection();
return conn.getInputStream();
我可以完美地从浏览器/提要阅读器访问 URL。但是,在 Java 中运行代码时,我得到一个
Exception in thread "main" java.net.UnknownHostException: weather.yahooapis.com
任何想法,可能是什么问题?可能是我们办公室的代理阻止了 URL,但是我可以从浏览器访问它吗?
最好的,威尔