jaireltonPJ
URL url = new URL("http://xml.weather.yahoo.com/forecastrss?p=94089");
SocketAddress addr = new InetSocketAddress("proxy.fazenda.mg.gov.br", 8003);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
HttpURLConnection con = (HttpURLConnection) url.openConnection(proxy);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String xml = "";
while(in.ready()){
xml += in.readLine();
xml += "\n";
}
con.disconnect();
Mas se você quer ler RSS tem uma API pra isso:
http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/rss_utils_1.1.zip
URL url = new URL("http://xml.weather.yahoo.com/forecastrss?p=94089");
RssParser parser = RssParserFactory.createDefault();
Rss rss = parser.parse (url);
Collection items = rss.getChannel().getItems();
Iterator ite = items.iterator();
while(ite.hasNext()){
Item item = (Item) i.next();
System.out.println("Titulo: " + item.getTitle());
System.out.println("Link: " + item.getLink());
System.out.println("Descrição: " + item.getDescription());
}
felipeloPJ
Valew cara… funcionou beleza…