Top Description Fields Methods
jdk.internal.util.xml

public Interface XMLStreamWriter

Known Direct Implementers
jdk.internal.util.xml.impl.XMLStreamWriterImpl
Imports
java.nio.charset.Charset, .StandardCharsets

Basic XMLStreamWriter for writing simple XML files such as those defined in java.util.Properties This is a subset of javax.xml.stream.XMLStreamWriter
Author
Joe Wang

Field Summary

Modifier and TypeField and Description
public static final Charset
public static final String
public static final String

Method Summary

Modifier and TypeMethod and Description
public void
close()

Close this writer and free any resources associated with the writer.

public void
flush()

Write any cached data to the underlying output mechanism.

public void
writeAttribute(String
the local name of the attribute
localName
,
String
the value of the attribute
value
)

Writes an attribute to the output stream without a prefix.

public void
writeCData(String
the data contained in the CData Section, may not be null
data
)

Writes a CData section

public void
writeCharacters(String
the value to write
text
)

Write text to the output

public void
writeCharacters(char[]
the value to write
text
,
int
the starting position in the array
start
,
int
the number of characters to write
len
)

Write text to the output

public void
writeDTD(String
the DTD to be written
dtd
)

Write a DTD section.

public void
writeEmptyElement(String
local name of the tag, may not be null
localName
)

Writes an empty element tag to the output

public void
writeEndDocument()

Closes any start tags and writes corresponding end tags.

public void
writeEndElement()

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

public void
writeStartDocument()

Write the XML Declaration.

public void
writeStartDocument(String
version of the xml document
version
)

Write the XML Declaration.

public void
writeStartDocument(String
encoding of the xml declaration
encoding
,
String
version of the xml document
version
)

Write the XML Declaration.

public void
writeStartElement(String
local name of the tag, may not be null
localName
)

Writes a start tag to the output.

Field Detail

DEFAULT_CHARSETback to summary
public static final Charset DEFAULT_CHARSET
DEFAULT_ENCODINGback to summary
public static final String DEFAULT_ENCODING
DEFAULT_XML_VERSIONback to summary
public static final String DEFAULT_XML_VERSION

Method Detail

closeback to summary
public void close() throws XMLStreamException

Close this writer and free any resources associated with the writer. This must not close the underlying output stream.

flushback to summary
public void flush() throws XMLStreamException

Write any cached data to the underlying output mechanism.

writeAttributeback to summary
public void writeAttribute(String localName, String value) throws XMLStreamException

Writes an attribute to the output stream without a prefix.

Parameters
localName:String

the local name of the attribute

value:String

the value of the attribute

Exceptions
IllegalStateException:
if the current state does not allow Attribute writing
writeCDataback to summary
public void writeCData(String data) throws XMLStreamException

Writes a CData section

Parameters
data:String

the data contained in the CData Section, may not be null

writeCharactersback to summary
public void writeCharacters(String text) throws XMLStreamException

Write text to the output

Parameters
text:String

the value to write

writeCharactersback to summary
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException

Write text to the output

Parameters
text:char[]

the value to write

start:int

the starting position in the array

len:int

the number of characters to write

writeDTDback to summary
public void writeDTD(String dtd) throws XMLStreamException

Write a DTD section. This string represents the entire doctypedecl production from the XML 1.0 specification.

Parameters
dtd:String

the DTD to be written

writeEmptyElementback to summary
public void writeEmptyElement(String localName) throws XMLStreamException

Writes an empty element tag to the output

Parameters
localName:String

local name of the tag, may not be null

writeEndDocumentback to summary
public void writeEndDocument() throws XMLStreamException

Closes any start tags and writes corresponding end tags.

writeEndElementback to summary
public void writeEndElement() throws XMLStreamException

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

writeStartDocumentback to summary
public void writeStartDocument() throws XMLStreamException

Write the XML Declaration. Defaults the XML version to 1.0, and the encoding to utf-8

writeStartDocumentback to summary
public void writeStartDocument(String version) throws XMLStreamException

Write the XML Declaration. Defaults the encoding to utf-8

Parameters
version:String

version of the xml document

writeStartDocumentback to summary
public void writeStartDocument(String encoding, String version) throws XMLStreamException

Write the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying output. That must be set when the instance of the XMLStreamWriter is created using the XMLOutputFactory

Parameters
encoding:String

encoding of the xml declaration

version:String

version of the xml document

Exceptions
XMLStreamException:
If given encoding does not match encoding of the underlying stream
writeStartElementback to summary
public void writeStartElement(String localName) throws XMLStreamException

Writes a start tag to the output. All writeStartElement methods open a new scope in the internal namespace context. Writing the corresponding EndElement causes the scope to be closed.

Parameters
localName:String

local name of the tag, may not be null