Class XMLStreamWriterUtil


  • public class XMLStreamWriterUtil
    extends Object

    XMLStreamWriterUtil provides some utility methods intended to be used in conjunction with a StAX XMLStreamWriter.

    Author:
    [email protected]
    • Method Detail

      • getOutputStream

        @Nullable
        public static OutputStream getOutputStream​(XMLStreamWriter writer)
                                            throws XMLStreamException
        Gives the underlying stream for XMLStreamWriter. It closes any start elements, and returns the stream so that JAXB can write infoset directly to the stream.
        Parameters:
        writer - XMLStreamWriter for which stream is required
        Returns:
        underlying OutputStream, null if writer doesn't provide a way to get it
        Throws:
        XMLStreamException - if any of writer operations throw the exception
      • getEncoding

        @Nullable
        public static String getEncoding​(XMLStreamWriter writer)
        Gives the encoding with which XMLStreamWriter is created.
        Parameters:
        writer - XMLStreamWriter for which encoding is required
        Returns:
        null if cannot be found, else the encoding