Example usage for org.apache.commons.io.input XmlStreamReader XmlStreamReader

List of usage examples for org.apache.commons.io.input XmlStreamReader XmlStreamReader

Introduction

In this page you can find the example usage for org.apache.commons.io.input XmlStreamReader XmlStreamReader.

Prototype

public XmlStreamReader(InputStream is, String httpContentType, boolean lenient) throws IOException 

Source Link

Document

Creates a Reader using an InputStream an the associated content-type header.

Usage

From source file:com.c4om.jschematronvalidator.JSchematronValidatorMain.java

/**
 * Reads a {@link org.w3c.dom.Document} from an {@link InputStream}. Encoding is automatically 
 * determined as specified by corresponding RFCs.
 * @param is the input stream.//  w  ww . ja  v  a  2  s  .  c o  m
 * @param encoding the fallback encoding, if the actual one could not be determined
 * @return the read {@link Document}
 * @throws ParserConfigurationException
 * @throws SAXException
 * @throws IOException
 */
public static Document loadW3CDocumentFromInputStream(InputStream is, String encoding)
        throws ParserConfigurationException, SAXException, IOException {
    Reader xmlStreamReader = new XmlStreamReader(is, true, encoding);
    return loadW3CDocumentFromInputSource(new InputSource(xmlStreamReader));
}

From source file:org.codehaus.mojo.jspc.CompilationMojoSupport.java

protected String readXmlToString(File f) throws MojoExecutionException {
    Reader reader = null;/*w w  w.j a  v a 2s .c om*/
    try {
        reader = new XmlStreamReader(new BufferedInputStream(new FileInputStream(f)), true, this.javaEncoding);

        return IOUtils.toString(reader);
    } catch (IOException e) {
        throw new MojoExecutionException(
                "Failed to read '" + f + "' as XML file with default encoding: " + this.javaEncoding, e);
    } finally {
        IOUtils.closeQuietly(reader);
    }
}