public class XMLWriter
extends java.lang.Object
XMLTagWriter tree.
Use like this:
XMLWriter wr = new XMLWriter(
new FileWriter( "test.xml" ),
new MyRootTagWriter()
);
// optionally define the DTD
wr.setDtd(
new String[]{
"faces-config" // name
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN", // public
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd" // system
}
);
// optionally set encoding
wr.setEncoding("UTF-8");
// write
try
{
wr.write( new MyRootDataObject() );
}
catch( XMLWriteException e )
{
// report some error
}
finally
{
try{ wr.close() } catch( IOException e ){}
}
| Constructor and Description |
|---|
XMLWriter(java.io.OutputStream os,
XMLTagWriter root)
Creates a new xml writer which wraps a exiting
OutputStream. |
XMLWriter(java.io.Writer wr,
XMLTagWriter root)
Creates a new xml writer which wraps a exiting
Writer. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected XMLOutputter |
createXMLOutputter(java.io.Writer wr) |
protected void |
endDocument(XMLOutputter xout) |
java.lang.String[] |
getDtd() |
java.lang.String |
getEncoding() |
java.lang.String |
getIndent() |
LineBreak |
getLineBreak() |
char |
getQuotation() |
XMLTagWriter |
getRootTagWriter() |
void |
setDtd(java.lang.String[] dtd) |
void |
setEncoding(java.lang.String encoding) |
void |
setIndent(java.lang.String indent) |
void |
setLineBreak(LineBreak lineBreak) |
void |
setQuotation(char quotation) |
protected void |
startDocument(XMLOutputter xout) |
void |
write(java.lang.Object o) |
public XMLWriter(java.io.Writer wr,
XMLTagWriter root)
Writer.wr - the underlying writerroot - the root tag writer, must contain all sub tag writers of the documentpublic XMLWriter(java.io.OutputStream os,
XMLTagWriter root)
OutputStream.os - the underlying output streamroot - the root tag writer, must contain all sub tag writers of the documentprotected XMLOutputter createXMLOutputter(java.io.Writer wr)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionpublic void write(java.lang.Object o)
throws XMLWriteException
XMLWriteExceptionprotected void startDocument(XMLOutputter xout)
throws XMLWriteException
XMLWriteExceptionprotected void endDocument(XMLOutputter xout)
public void close()
throws java.lang.IllegalStateException,
java.io.IOException
java.lang.IllegalStateExceptionjava.io.IOExceptionpublic java.lang.String[] getDtd()
public void setDtd(java.lang.String[] dtd)
public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
public java.lang.String getIndent()
public void setIndent(java.lang.String indent)
public LineBreak getLineBreak()
public void setLineBreak(LineBreak lineBreak)
public char getQuotation()
public void setQuotation(char quotation)
public XMLTagWriter getRootTagWriter()
Copyright © 2018 SAP SE. All Rights Reserved.