public class XmlStreamWriter
extends java.io.Writer
To build an instance, see XmlStreamWriter.Builder
.
XmlStreamReader
Modifier and Type | Class and Description |
---|---|
static class |
XmlStreamWriter.Builder
Builds a new
XmlStreamWriter instance. |
Modifier and Type | Field and Description |
---|---|
private static int |
BUFFER_SIZE |
private java.nio.charset.Charset |
charset |
private java.nio.charset.Charset |
defaultCharset |
private java.io.OutputStream |
out |
private java.io.StringWriter |
prologWriter |
private java.io.Writer |
writer |
Modifier | Constructor and Description |
---|---|
|
XmlStreamWriter(java.io.File file)
Deprecated.
|
|
XmlStreamWriter(java.io.File file,
java.lang.String defaultEncoding)
Deprecated.
|
|
XmlStreamWriter(java.io.OutputStream out)
Deprecated.
|
private |
XmlStreamWriter(java.io.OutputStream out,
java.nio.charset.Charset defaultEncoding)
Constructs a new XML stream writer for the specified output stream
with the specified default encoding.
|
|
XmlStreamWriter(java.io.OutputStream out,
java.lang.String defaultEncoding)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static XmlStreamWriter.Builder |
builder()
Constructs a new
XmlStreamWriter.Builder . |
void |
close()
Closes the underlying writer.
|
private void |
detectEncoding(char[] cbuf,
int off,
int len)
Detects the encoding.
|
void |
flush()
Flushes the underlying writer.
|
java.lang.String |
getDefaultEncoding()
Returns the default encoding.
|
java.lang.String |
getEncoding()
Returns the detected encoding.
|
void |
write(char[] cbuf,
int off,
int len)
Writes the characters to the underlying writer, detecting encoding.
|
private static final int BUFFER_SIZE
private final java.io.OutputStream out
private final java.nio.charset.Charset defaultCharset
private java.io.StringWriter prologWriter
private java.io.Writer writer
private java.nio.charset.Charset charset
@Deprecated public XmlStreamWriter(java.io.File file) throws java.io.FileNotFoundException
builder()
, XmlStreamWriter.Builder
, and XmlStreamWriter.Builder.get()
file
- The file to write tojava.io.FileNotFoundException
- if there is an error creating or
opening the file@Deprecated public XmlStreamWriter(java.io.File file, java.lang.String defaultEncoding) throws java.io.FileNotFoundException
builder()
, XmlStreamWriter.Builder
, and XmlStreamWriter.Builder.get()
file
- The file to write todefaultEncoding
- The default encoding if not encoding could be detectedjava.io.FileNotFoundException
- if there is an error creating or
opening the file@Deprecated public XmlStreamWriter(java.io.OutputStream out)
builder()
, XmlStreamWriter.Builder
, and XmlStreamWriter.Builder.get()
out
- The output streamprivate XmlStreamWriter(java.io.OutputStream out, java.nio.charset.Charset defaultEncoding)
out
- The output streamdefaultEncoding
- The default encoding if not encoding could be detected@Deprecated public XmlStreamWriter(java.io.OutputStream out, java.lang.String defaultEncoding)
builder()
, XmlStreamWriter.Builder
, and XmlStreamWriter.Builder.get()
out
- The output streamdefaultEncoding
- The default encoding if not encoding could be detectedpublic static XmlStreamWriter.Builder builder()
XmlStreamWriter.Builder
.XmlStreamWriter.Builder
.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
- if an error occurs closing the underlying writerprivate void detectEncoding(char[] cbuf, int off, int len) throws java.io.IOException
cbuf
- the buffer to write the characters fromoff
- The start offsetlen
- The number of characters to writejava.io.IOException
- if an error occurs detecting the encodingpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
- if an error occurs flushing the underlying writerpublic java.lang.String getDefaultEncoding()
public java.lang.String getEncoding()
public void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.Writer
cbuf
- the buffer to write the characters fromoff
- The start offsetlen
- The number of characters to writejava.io.IOException
- if an error occurs detecting the encoding