Class XmlStreamUtils


  • public class XmlStreamUtils
    extends Object
    Utilities for working with xml streams
    • Method Detail

      • readHeadExcludeVersion

        public static byte[] readHeadExcludeVersion​(InputStream inputStream,
                                                    byte[] tag)
                                             throws IllegalArgumentException,
                                                    IOException
        Read input stream until the specified xml tag ends, return byte array of read data without "version" attribute from given tag.
        Parameters:
        inputStream - the underlying input stream, cannot be null
        tag - byte array presentation of xml tag, cannot be null
        Returns:
        return byte array of read data without "version" attribute from given tag, never null
        Throws:
        IllegalArgumentException - if no match is found before the read default buffer overflows occurs.
        IOException - if an I/O error occurs.
      • readHeadExcludeVersion

        public static byte[] readHeadExcludeVersion​(InputStream inputStream,
                                                    byte[] tag,
                                                    int limit)
                                             throws IllegalArgumentException,
                                                    IOException
        Read input stream until the specified xml tag ends, return byte array of read data without "version" attribute from given tag.
        Parameters:
        inputStream - the underlying input stream, cannot be null
        tag - byte array presentation of xml tag, cannot be null
        limit - the buffer read limit
        Returns:
        return byte array of read data without "version" attribute from given tag, never null
        Throws:
        IllegalArgumentException - if no match is found before the read default buffer overflows occurs.
        IOException - if an I/O error occurs.
      • readHeadIncludeVersion

        public static byte[] readHeadIncludeVersion​(InputStream inputStream,
                                                    byte[] tag,
                                                    String xmlFormatVersion)
                                             throws IllegalArgumentException,
                                                    IOException
        Read input stream until the specified xml tag ends, return byte array of read data with "version" attribute at the end of given tag.
        Parameters:
        inputStream - the underlying input stream, cannot be null
        tag - byte array presentation of xml tag, cannot be null
        xmlFormatVersion - the string presentation of xml format version, cannot be null
        Returns:
        return byte array of read data with "version" attribute for given tag, never null
        Throws:
        IllegalArgumentException - if no match is found before the read default buffer overflows occurs.
        IOException - if an I/O error occurs.
      • readHeadIncludeVersion

        public static byte[] readHeadIncludeVersion​(InputStream inputStream,
                                                    byte[] tag,
                                                    String xmlFormatVersion,
                                                    int limit)
                                             throws IllegalArgumentException,
                                                    IOException
        Read input stream until the specified xml tag ends, return byte array of read data with "version" attribute at the end of given tag.
        Parameters:
        inputStream - the underlying input stream, cannot be null
        tag - byte array presentation of xml tag, cannot be null
        xmlFormatVersion - the string presentation of xml format version, cannot be null
        limit - the buffer read limit
        Returns:
        return byte array of read data with "version" attribute for given tag, never null
        Throws:
        IllegalArgumentException - if no match is found before the read default buffer overflows occurs.
        IOException - if an I/O error occurs.
      • skipElement

        public static void skipElement​(InputStream inputStream,
                                       byte[] tag)
                                throws IllegalArgumentException,
                                       IOException
        Read input stream until the specified xml tag ends
        Parameters:
        inputStream - the underlying input stream, cannot be null
        tag - byte array presentation of xml tag, cannot be null
        Throws:
        IllegalArgumentException - if no match is found before the read default buffer overflows occurs.
        IOException - if an I/O error occurs.
      • createEmptyLastLineOutputStream

        public static OutputStream createEmptyLastLineOutputStream​(OutputStream outputStream)
        Create custom implementation of FilterOutputStream which adds an empty line (if there was none) when closing the stream
        Parameters:
        outputStream - the underlying output stream, cannot be null
        Returns:
        custom output stream, nevet null
      • createOsLineSeporatorOutputStream

        public static OutputStream createOsLineSeporatorOutputStream​(OutputStream outputStream)