Java XML String Transform writeResultToFile(final StreamResult result, final String path)

Here you can find the source of writeResultToFile(final StreamResult result, final String path)

Description

save StreamResult to file given in path

License

Open Source License

Declaration

public static void writeResultToFile(final StreamResult result,
        final String path) 

Method Source Code

//package com.java2s;

import java.io.BufferedWriter;

import java.io.FileWriter;
import java.io.IOException;

import javax.xml.transform.stream.StreamResult;

public class Main {
    /**/* w ww.j a v  a 2 s. c  om*/
     * save StreamResult to file given in path
     */
    public static void writeResultToFile(final StreamResult result,
            final String path) {
        final String fileString = result.getWriter().toString();

        try {
            final BufferedWriter out = new BufferedWriter(new FileWriter(
                    path));
            out.write(fileString);
            out.close();
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. toString(Source input)
  2. write(Node node, OutputStream out, String... props)
  3. writeElement(Element element, String fileName)
  4. writeNodeSubtreeXMLString(final Node node, final Writer writer)
  5. writePropToString(Properties props)
  6. writeToFile(String xmlContent, String path)
  7. writeXML(Node node, String dtdFilename, String outputFileName)
  8. writeXml(OutputStream os, Node node, String encoding)
  9. writeXmlFile(Element doc, String filename)