Java Code Examples for javax.xml.transform.stream.StreamResult.setOutputStream()

The following are Jave code examples for showing how to use setOutputStream() of the javax.xml.transform.stream.StreamResult class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: oscm   File: WsdlHandleTask.java   View Source Code Vote up 6 votes
private void save(String fileName, Document doc)
        throws TransformerException, IOException {
    TransformerFactory transFactory = TransformerFactory.newInstance();
    Transformer transformer = transFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.setOutputProperty(
            "{http://xml.apache.org/xslt}indent-amount", "4");
    DOMSource source = new DOMSource();
    source.setNode(doc);
    StreamResult result = new StreamResult();
    OutputStream out = new FileOutputStream(fileName);
    result.setOutputStream(out);
    transformer.transform(source, result);
    out.close();
}
 
Example 2
Project: OpenJSharp   File: XMLOutputFactoryImpl.java   View Source Code Vote up 5 votes
/** StreamResult object is re-used and the values are set appropriately.
 */
StreamResult toStreamResult(OutputStream os, Writer writer, String systemId){
    StreamResult sr = new StreamResult();
    sr.setOutputStream(os);
    sr.setWriter(writer);
    sr.setSystemId(systemId);
    return sr;
}
 
Example 3
Project: openjdk-jdk10   File: XMLOutputFactoryImpl.java   View Source Code Vote up 5 votes
/** StreamResult object is re-used and the values are set appropriately.
 */
StreamResult toStreamResult(OutputStream os, Writer writer, String systemId){
    StreamResult sr = new StreamResult();
    sr.setOutputStream(os);
    sr.setWriter(writer);
    sr.setSystemId(systemId);
    return sr;
}