Here you can find the source of writeResultToFile(final StreamResult result, final String path)
public static void writeResultToFile(final StreamResult result, final String path)
//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(); } } }