Here you can find the source of createXMLStreamReaderFromReader(final Reader reader)
Parameter | Description |
---|---|
reader | An <code>InputStreamReader</code> object that represents the input reader to use as the source. |
Parameter | Description |
---|---|
XMLStreamException | If the XML stream reader could not be created. |
java.xml.stream.XMLStreamReader
object that represents the XML stream reader created from the specified input stream.
public static XMLStreamReader createXMLStreamReaderFromReader(final Reader reader) throws XMLStreamException
//package com.java2s; /**//from www . j a va2 s . c o m * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.Reader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; public class Main { /** * Creates an XML stream reader from the specified input stream. * * @param reader * An <code>InputStreamReader</code> object that represents the input reader to use as the source. * * @return A <code>java.xml.stream.XMLStreamReader</code> object that represents the XML stream reader created from * the specified input stream. * * @throws XMLStreamException * If the XML stream reader could not be created. */ public static XMLStreamReader createXMLStreamReaderFromReader(final Reader reader) throws XMLStreamException { XMLInputFactory xmlif = null; xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); // set the IS_COALESCING property to true , if application desires to // get whole text data as one event. xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); return xmlif.createXMLStreamReader(reader); } }