Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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.
 */

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));
    }
}