org.apache.commons.io.input.XmlStreamReader Java Examples

The following examples show how to use org.apache.commons.io.input.XmlStreamReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FeedHandler.java    From AntennaPodSP with MIT License 6 votes vote down vote up
public Feed parseFeed(Feed feed) throws SAXException, IOException,
        ParserConfigurationException, UnsupportedFeedtypeException {
    TypeGetter tg = new TypeGetter();
    TypeGetter.Type type = tg.getType(feed);
    SyndHandler handler = new SyndHandler(feed, type);

    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    SAXParser saxParser = factory.newSAXParser();
    File file = new File(feed.getFile_url());
    Reader inputStreamReader = new XmlStreamReader(file);
    InputSource inputSource = new InputSource(inputStreamReader);

    saxParser.parse(inputSource, handler);
    inputStreamReader.close();
    return handler.state.feed;
}
 
Example #2
Source File: MiscUtil.java    From LicenseScout with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an XML InputSource from an InputStream with the correct
 * encoding.
 * 
 * @param inputStream
 * @return an input source for an XML parser
 * @throws IOException
 * 
 * @see {@link XmlStreamReader}
 */
public static InputSource getInputSource(final InputStream inputStream) throws IOException {
    final Reader reader = new XmlStreamReader(inputStream);
    return new InputSource(reader);
}