Passa ai contenuti principali

Post

Visualizzazione dei post da Dicembre, 2012

org.w3c.dom.Document convertion Utils

How to convert an InputStream to a Document?
How to contert a Document to an InputStream? The snippet of code posted is an utility Java Class written in Java for org.w3c.dom.Document convertions, it supports:

Document to StringString to DocumentDocument to InputStreamInputStream to Document
package org.gma.util; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class DocumentUtils { /** * Convert a document to an Inputstream * @param document the document to convert * @param prettyPrint prettyPri…