2019独角兽企业重金招聘Python工程师标准>>>
package com.ninemax.application.rss;import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.zip.GZIPInputStream;import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;public class RssPraseByOne {/*** 根据链接地址解析数据* * @param url* RSS形式的xml文件* * @throws Exception*/@SuppressWarnings("unchecked")public void praseXml(URL url) throws Exception {SyndFeed feed = null;SyndFeedInput input = new SyndFeedInput();// 创建链接对象URLConnection conn = url.openConnection();String content_encoding = conn.getHeaderField("Content-Encoding");if (content_encoding != null && content_encoding.contains("gzip")) {System.out.println("conent encoding is gzip");GZIPInputStream gzin = new GZIPInputStream(conn.getInputStream());feed = input.build(new XmlReader(gzin));} else {//1.得到此链接的输入流//2.读取此输入流//3.得到此输入流的有效信息feed = input.build(new XmlReader(conn.getInputStream()));}// 得到XML的所有实体List
输出:
动态加载多说评论
Java缓存框架Ehcache使用
后台判断Ajax请求
Windows批处理切换IP地址
Linux搭建SVN+Apache
Chrome快捷键大全
童言无忌
分享Typecho主题sexful
Java操作图数据库Titan
MapReduce性能优化小结
feed size:10