Java 类javax.xml.stream.util.StreamReaderDelegate 实例源码

项目:bag-etl    文件:XMLStreamReaderUtils.java   
public static XMLStreamReader getXMLStreamReader(InputStream is) throws XMLStreamException, FactoryConfigurationError
{
    //return XMLInputFactory.newInstance().createXMLStreamReader(is);
    return new StreamReaderDelegate(XMLInputFactory.newInstance().createXMLStreamReader(is))
    {
        public int next() throws XMLStreamException
        {
            while (true)
            {
                int event = super.next();
                switch (event)
                {
                    case XMLStreamConstants.COMMENT:
                    case XMLStreamConstants.PROCESSING_INSTRUCTION:
                        continue;
                    default:
                        return event;
                }
            }
        }
    };
}