Class OutStreamUTF8

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public final class OutStreamUTF8
    extends java.io.Writer
    Output UTF-8 encoded data. This class implements the "Modified UTF8" encoding rules (null -> C0 80) It will encode any 16 bit value. It can be used as a pure UTF-8 encoder.
    See Also:
    InStreamUTF8
    • Constructor Summary

      Constructors 
      Constructor Description
      OutStreamUTF8​(java.io.OutputStream out)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static byte[] encode​(int ch)
      Return a byte array with the UTF-8 encoding of the integer
      void flush()  
      void output​(int x)  
      static void output​(java.io.OutputStream out, int ch)  
      void write​(char[] b)  
      void write​(char[] cbuf, int off, int len)  
      void write​(int ch)  
      void write​(java.lang.String str)  
      void write​(java.lang.String str, int idx, int len)  
      • Methods inherited from class java.io.Writer

        append, append, append, nullWriter
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OutStreamUTF8

        public OutStreamUTF8​(java.io.OutputStream out)
    • Method Detail

      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws java.io.IOException
        Specified by:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(int ch)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(char[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(java.lang.String str)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(java.lang.String str,
                          int idx,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • output

        public void output​(int x)
      • encode

        public static byte[] encode​(int ch)
        Return a byte array with the UTF-8 encoding of the integer
      • output

        public static void output​(java.io.OutputStream out,
                                  int ch)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
        Throws:
        java.io.IOException