public class XMLWriter
extends java.io.Writer
XMLWriter is not thread safe.
For efficiency this writer buffers the input. Use flush() function
to explicitly write the data to underlying stream.
This writer is designed in such a way that it atleast buffers the input to the
size specified. Unless flush is called, it guarantees that
data in chunks of size equal to or more than size specified will be written.
XMLWriter instance can be reused. setWriter() internally clears the
buffer and stores the reference to newly supplied Writer instance.| Constructor and Description |
|---|
XMLWriter(java.io.Writer writer)
Creates the instance of
XMLWriter |
XMLWriter(java.io.Writer writer,
int size)
Creates the instnace of
XMLWriter. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the stream, flushing it first.
|
void |
flush()
Flush the stream.
|
protected java.io.Writer |
getWriter()
Returns underlying
Writer |
void |
reset()
Reset this Writer.
|
void |
setWriter(java.io.Writer writer)
Set the given
Writer. |
void |
setWriter(java.io.Writer writer,
int size)
Set the given
Writer |
void |
write(char[] cbuf)
Write an array of characters.
|
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters.
|
void |
write(int c)
Write a single character.
|
void |
write(java.lang.String str)
Write a string.
|
void |
write(java.lang.String str,
int off,
int len)
Write a portion of a string.
|
public XMLWriter(java.io.Writer writer)
XMLWriterpublic XMLWriter(java.io.Writer writer,
int size)
XMLWriter.
atleast buffers the input to the
size specified.public void write(int c)
throws java.io.IOException
Subclasses that intend to support efficient single-character output should override this method.
write in class java.io.Writerc - int specifying a character to be written.java.io.IOException - If an I/O error occurspublic void write(char[] cbuf)
throws java.io.IOException
write in class java.io.Writercbuf - Array of characters to be writtenjava.io.IOException - If an I/O error occurspublic void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.Writercbuf - Array of charactersoff - Offset from which to start writing characterslen - Number of characters to writejava.io.IOException - If an I/O error occurspublic void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerstr - A Stringoff - Offset from which to start writing characterslen - Number of characters to writejava.io.IOException - If an I/O error occurspublic void write(java.lang.String str)
throws java.io.IOException
write in class java.io.Writerstr - String to be writtenjava.io.IOException - If an I/O error occurspublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOException - If an I/O error occurspublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOException - If an I/O error occurspublic void reset()
public void setWriter(java.io.Writer writer)
Writer.Writer - Writer.public void setWriter(java.io.Writer writer,
int size)
WriterWriter - Writer.int - Writer will buffer the character data size, after that data is written to stream.protected java.io.Writer getWriter()
WriterCopyright ? 2002-2003 Apache XML Project. All Rights Reserved.