Class XMLWriter


  • public class XMLWriter
    extends XMLWriterSupport
    A class for writing XML to a character stream.
    • Field Detail

      • writer

        private java.io.Writer writer
        The character stream.
    • Constructor Detail

      • XMLWriter

        public XMLWriter​(java.io.Writer writer)
        Creates a new XML writer for the specified character stream. By default, four spaces are used for indentation.
        Parameters:
        writer - the character stream.
      • XMLWriter

        public XMLWriter​(java.io.Writer writer,
                         java.lang.String indentString)
        Creates a new XML writer for the specified character stream.
        Parameters:
        writer - the character stream.
        indentString - the string used for indentation (should contain white space, for example four spaces).
    • Method Detail

      • writeXmlDeclaration

        public void writeXmlDeclaration()
                                 throws java.io.IOException
        Writes the XML declaration that usually appears at the top of every XML file.
        Throws:
        java.io.IOException - if there is a problem writing to the character stream.
      • writeTag

        public void writeTag​(java.lang.String name,
                             boolean close)
                      throws java.io.IOException
        Writes an opening XML tag that has no attributes.
        Parameters:
        name - the tag name.
        close - a flag that controls whether or not the tag is closed immediately.
        Throws:
        java.io.IOException - if there is an I/O problem.
      • writeCloseTag

        public void writeCloseTag​(java.lang.String tag)
                           throws java.io.IOException
        Writes a closing XML tag.
        Parameters:
        tag - the tag name.
        Throws:
        java.io.IOException - if there is an I/O problem.
      • writeTag

        public void writeTag​(java.lang.String name,
                             java.lang.String attributeName,
                             java.lang.String attributeValue,
                             boolean close)
                      throws java.io.IOException
        Writes an opening XML tag with an attribute/value pair.
        Parameters:
        name - the tag name.
        attributeName - the attribute name.
        attributeValue - the attribute value.
        close - controls whether the tag is closed.
        Throws:
        java.io.IOException - if there is an I/O problem.
      • writeTag

        public void writeTag​(java.lang.String name,
                             AttributeList attributes,
                             boolean close)
                      throws java.io.IOException
        Writes an opening XML tag along with a list of attribute/value pairs.
        Parameters:
        name - the tag name.
        attributes - the attributes.
        close - controls whether the tag is closed.
        Throws:
        java.io.IOException - if there is an I/O problem.
      • writeTag

        public void writeTag​(java.lang.String name,
                             java.util.Properties attributes,
                             boolean close)
                      throws java.io.IOException
        Deprecated.
        use the attribute list instead ...
        Writes an opening XML tag along with a list of attribute/value pairs.
        Parameters:
        name - the tag name.
        attributes - the attributes.
        close - controls whether the tag is closed.
        Throws:
        java.io.IOException - if there is an I/O problem.
      • writeText

        public void writeText​(java.lang.String text)
                       throws java.io.IOException
        Writes some text to the character stream.
        Parameters:
        text - the text.
        Throws:
        java.io.IOException - if there is a problem writing to the character stream.
      • close

        public void close()
                   throws java.io.IOException
        Closes the underlying character stream.
        Throws:
        java.io.IOException - if there is a problem closing the character stream.