簡體   English   中英

將XML文件放入InputStream

[英]put XML file into InputStream

我想將http://www.nasa.gov/rss/dyn/image_of_the_day.rss放入FileInputStream中的任何建議我該怎么做。

您無法從該URL讀取到FileInputStream中,因為它不是文件。 但是,您可以讀入InputStream:

InputStream input = new URL("http://www.nasa.gov/rss/dyn/image_of_the_day.rss").openStream();

通過使用java.net.URL構造這樣的新對象。 URL url =新網址(“ http://www.nasa.gov/rss/dyn/image_of_the_day.rss ”); 然后簡單地調用url.openStream(); //這將返回InputStream對象

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM