Java XML Document Transform transfer(Document doc, String filepath)

Here you can find the source of transfer(Document doc, String filepath)

Description

transfer

License

Apache License

Declaration

public static void transfer(Document doc, String filepath) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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 {
    private static TransformerFactory tff;

    public static void transfer(Document doc, String filepath) {
        try {//from  ww  w  . ja  v  a  2  s. c  o m
            Transformer tf = tff.newTransformer();
            DOMSource source = new DOMSource(doc);
            StreamResult result = new StreamResult(filepath);
            tf.transform(source, result);
        } catch (TransformerConfigurationException e) {
            e.printStackTrace();
        } catch (TransformerException e) {
            e.printStackTrace();
        }

    }
}

Related

  1. transform(Document doc, Result result)
  2. transform(Document doc, Result result)
  3. transform(Document doc, StreamSource xslInput, String systemid)
  4. transform(Document document, Properties outputProperties, StreamResult streamResult)