Java XML Document Save to File saveToDisk(Document doc, OutputStream out)

Here you can find the source of saveToDisk(Document doc, OutputStream out)

Description

save To Disk

License

Open Source License

Declaration

public static void saveToDisk(Document doc, OutputStream out)
            throws TransformerConfigurationException, TransformerException 

Method Source Code


//package com.java2s;
/* Copyright (c) 2013 Intecs - www.intecs.it. All rights reserved.
 * This code is licensed under the GPL 3.0 license, available at the root
 * application directory./*from  w  ww  . ja va2  s . co  m*/
*/

import java.io.*;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

public class Main {
    public static void saveToDisk(Document doc, OutputStream out)
            throws TransformerConfigurationException, TransformerException {
        Transformer serializer = TransformerFactory.newInstance().newTransformer();
        serializer.transform(new DOMSource(doc), new StreamResult(out));
    }

    public static void saveToDisk(Document doc, OutputStream out, boolean indent)
            throws TransformerConfigurationException, TransformerException {
        saveToDisk(doc, out);
    }

    public static void saveToDisk(Document doc, File file)
            throws FileNotFoundException, TransformerConfigurationException, TransformerException {
        saveToDisk(doc, new FileOutputStream(file));
    }
}

Related

  1. saveDomToFile(Document doc, String filePath)
  2. saveHumanReadable(Document document, File file)
  3. saveImpl(Document document, StreamResult output, Properties outputProperties)
  4. saveReportToFile(Node node, String documentFileName)
  5. saveTemporaryDocument(Document document, String folderName)
  6. saveToFile(Document doc, File f, boolean indent)
  7. saveToFile(String filename, Document document)
  8. saveToXml(Document doc, OutputStream os)
  9. saveToXmlStr(Document doc)