Example usage for org.w3c.dom.ls LSSerializer writeToURI

List of usage examples for org.w3c.dom.ls LSSerializer writeToURI

Introduction

In this page you can find the example usage for org.w3c.dom.ls LSSerializer writeToURI.

Prototype

public boolean writeToURI(Node nodeArg, String uri) throws LSException;

Source Link

Document

A convenience method that acts as if LSSerializer.write was called with a LSOutput with no encoding specified and LSOutput.systemId set to the uri argument.

Usage

From source file:Main.java

/**
 * Writes the given document to a file (pretty-printed)
 * //from  ww  w  .  j a v  a 2 s. co  m
 * @param doc Document to serialize
 * @param file File to write
 */
public static void writeDocument(Document doc, File file) {
    if (doc == null)
        return;
    LSSerializer writer = impl.createLSSerializer();
    writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
    writer.writeToURI(doc, file.toURI().toString());
}