2011-02-08 64 views
0

在Google App Engine框架中加载外部xml的最简单方法是什么?GAEJ:加载外部XML

我试了一下谷歌建议:

URL url = new URL("http://mydomain.com/data.xml"); 

BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); 
String line; 

while ((line = reader.readLine()) != null) { 
// ... 
} 
reader.close(); 

但它不工作。

它给line = null

+0

“It given line = null”when?立即?读完一些行后?你确定服务器不只是返回一个空的响应体? – 2011-02-09 03:07:44

回答

0

谢谢大家的帮助。这是由我在Java中的noobnes引起的不适当的恐慌。 这是这样处理的。 不好意思。

while ((line = reader.readLine()) != null) 
{ 
      xmlResponce = xmlResponce.concat(line); 

} 

reader.close(); 
3

为了能够从其他网站上,您将需要的物品URLFetch service
您是否尝试过在浏览器中获取页面?您是否尝试过独立程序示例?您也不指定您是在调试模式还是在GAE服务器上工作。你在防火墙后面吗?

+0

实际上OP正在使用URLFetch服务 – systempuntoout 2011-02-08 14:17:37