|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Writer java.io.FilterWriter org.apache.commons.xmlio.out.XMLWriter org.apache.commons.xmlio.out.XMLOutputStreamWriter
public class XMLOutputStreamWriter
Adds XML export functionality to the underlying output stream. Formatting and
encoding is done as straight forward as possible.
Everything you know better than this class must be done by you, e.g. you will
have to tell XMLOutputStreamWriter
where you wish to have
newlines.In effect, no unexpected so called
intelligent behavior is to be feared. Another effect is high speed.
Caution: Do not forget to call FilterWriter.flush()
at the end of your
exporting process as otherwise no data might be written.
Warning: When using two byte encoding (e.g. UTF-16) underlying
OutputStream can
not savely be brought to string. Do not use
ByteArrayOutputStream
with two byte encoding, as XML declaration
will be in single byte encoding (according to XML spec) and the rest will be
in double byte totally confusing ByteArrayOutputStream encoding to string.
If you want to have string output use XMLWriter
filtering
StringWriter
or for convenience XMLStringWriter
.
Field Summary | |
---|---|
static String |
ENCODING_ISO_8859_1
Name of ISO-8859-1 encoding |
static String |
ENCODING_ISO_LATIN1
Alias for ISO-8859-1 encoding |
static String |
ENCODING_STANDARD
Name of standard encoding |
static String |
ENCODING_UTF_16
Name of UTF-16 encoding |
static String |
ENCODING_UTF_8
Name of UTF-8 encoding |
protected String |
encodingName
|
protected OutputStream |
os
|
Fields inherited from class org.apache.commons.xmlio.out.XMLWriter |
---|
depth, indent, NEWLINE, nlAfterEmptyTag, nlAfterEndTag, nlAfterStartTag, NO_NEWLINE, prettyPrintMode, tabWidth, xmlDeclWritten |
Fields inherited from class java.io.FilterWriter |
---|
out |
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
XMLOutputStreamWriter(OutputStream os)
Creates a new output stream writer for XML export. |
|
XMLOutputStreamWriter(OutputStream os,
String encodingName)
Creates a new output stream writer for XML export. |
Method Summary | |
---|---|
String |
getEncodingName()
Gets the name of the encoding as it would be inserted into the XML declaration. |
void |
writeXMLDeclaration()
Writes XML delcaration using version 1.0 and encoding specified in constructor. |
Methods inherited from class java.io.FilterWriter |
---|
close, flush, write, write, write |
Methods inherited from class java.io.Writer |
---|
append, append, append, append, append, append, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String ENCODING_UTF_8
public static String ENCODING_UTF_16
public static String ENCODING_ISO_8859_1
public static String ENCODING_STANDARD
public static String ENCODING_ISO_LATIN1
protected OutputStream os
protected String encodingName
Constructor Detail |
---|
public XMLOutputStreamWriter(OutputStream os, String encodingName) throws UnsupportedEncodingException
os
- the underlying output stream the XML is exported toencodingName
- name of the encoding used to write XML as well as
for the XML declataration (e.g. UTF-8, ISO-8859-1, ...)
UnsupportedEncodingException
public XMLOutputStreamWriter(OutputStream os) throws UnsupportedEncodingException
ENCODING_STANDARD
, which usually is
UTF-8.
os
- the underlying output stream the XML is exported to
UnsupportedEncodingException
XMLOutputStreamWriter(OutputStream, String)
Method Detail |
---|
public String getEncodingName()
OutputStreamWriter.getEncoding()
may return something less verbose.
OutputStreamWriter.getEncoding()
public void writeXMLDeclaration() throws IOException
writeXMLDeclaration
in class XMLWriter
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |