public class XMLOutputStream
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
COMPACT |
static int |
DEFAULT |
static int |
NO_REUSE |
static int |
PRETTY |
static int |
REUSE |
Constructor and Description |
---|
XMLOutputStream(java.io.OutputStream outs)
Builds the ASCII output stream (as a byte stream)
|
XMLOutputStream(java.io.Writer outw)
Builds the output stream from a Writer (also PrintWriter) (as a character stream)
|
Modifier and Type | Method and Description |
---|---|
void |
addIndent(int offset)
Set indenting level for output
|
void |
close()
Closes the output stream.
|
void |
close(int option)
Closes the output stream based on the option.
|
void |
flush()
Flushes the internal buffer by writing it to the output stream
|
int |
getOutputStyle()
Gets the Current output style
|
void |
setEncoding(java.lang.String encoding, boolean lendian, boolean useByteOrderMark)
Sets the output character encoding for a byte stream.
|
void |
setEOLChars(java.lang.String nl)
Set newline characters
|
void |
setOutputStyle(int style)
Sets the Output the style
|
void |
write(int c)
Outputs character according to type of the output stream
|
void |
writeChars(java.lang.String str)
Write string to the output
|
void |
writeIndent()
Output the indentation
|
void |
writeNewLine()
Newline writer
|
void |
writeQuotedString(java.lang.String str)
Write string with surrounding quotes
|
public static final int DEFAULT
public static final int PRETTY
public static final int COMPACT
public static final int REUSE
public static final int NO_REUSE
public XMLOutputStream(java.io.OutputStream outs)
out
- the output streampublic XMLOutputStream(java.io.Writer outw)
out
- the Writer streampublic void setEOLChars(java.lang.String nl)
public void setEncoding(java.lang.String encoding, boolean lendian, boolean useByteOrderMark) throws java.io.IOException
encoding
- the encoding of the (byte) streamlendian
- flag to indicate if the encoding is of type little endianuseByteOrderMark
- flag for whether to write the byte order markjava.io.IOException
- if an error is thrown in setting the encoding typepublic void flush() throws java.io.IOException
java.io.IOException
- if there is any error in flushing the output streampublic void close() throws java.io.IOException
java.io.IOException
- if there is any error in closing the output streampublic void close(int option) throws java.io.IOException
option
- determines whether output stream has to be closed.java.io.IOException
- if there is any error in closing the output stream.public void write(int c) throws java.io.IOException
c
- the character that needs to be written. Note that c can be either a standard Unicode code point (i.e., using UTF-32 encoding); or it may be just one member of a surrogate pair, either a high surrogate or a low surrogate. I.e., for supplementary characters, which use surrogate pairs in UTF-16, we may have to call write() twice in order to write one logical character.java.io.IOException
- if there is any error in writing the characterpublic void writeChars(java.lang.String str) throws java.io.IOException
str
- the string that is written to the output streamjava.io.IOException
- error thrown if there is any error in writing the stringpublic void writeQuotedString(java.lang.String str) throws java.io.IOException
str
- the string that is written to the output streamjava.io.IOException
- error thrown if there is any error in writing the stringpublic void writeNewLine() throws java.io.IOException
java.io.IOException
- error thrown if there is any error in writing the stringpublic void addIndent(int offset)
offset
- the indenting levelpublic void writeIndent() throws java.io.IOException
java.io.IOException
- error thrown if there is any error in writing the stringpublic void setOutputStyle(int style)
style
- the output stylepublic int getOutputStyle()