Class HexOutputStream

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

    public class HexOutputStream
    extends java.io.OutputStream
    Writes each input byte as a 2 byte hexidecimal output pair making it possible to turn arbitrary binary data into an ASCII format. The high 4 bits of the byte is translated into the first byte.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static char[] hex  
      private java.io.StringWriter writer  
    • Constructor Summary

      Constructors 
      Constructor Description
      HexOutputStream​(java.io.StringWriter w)
      Creates a new HexOutputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(int b)
      Writes a byte.
      • Methods inherited from class java.io.OutputStream

        close, flush
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • hex

        private static final char[] hex
      • writer

        private java.io.StringWriter writer
    • Constructor Detail

      • HexOutputStream

        public HexOutputStream​(java.io.StringWriter w)
        Creates a new HexOutputStream.
        Parameters:
        w - The underlying StringWriter.
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Writes a byte. Will block until the byte is actually written. param b The byte to write out.
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException - I/O error occurred.
      • write

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

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException