Class HexOutputStream

java.lang.Object
java.io.OutputStream
org.refcodes.io.HexOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class HexOutputStream extends OutputStream
A HexOutputStream wraps an OutputStream printing out the bytes written to the HexOutputStream as hexadecimal text to the wrapped OutputStream. This is most useful in conjunction with either the OutputStreamComposite or the InputStreamTap to sniff data written to / read from the according stream while still forwarding the calls to original streams.
  • Constructor Details

    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream)
      Constructs a HexOutputStream with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, boolean isPrefixBytes)
      Constructs a HexOutputStream with the given arguments used for configuration.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      isPrefixBytes - When true, then 0x is prefixed to the HEX values.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak)
      Constructs a HexOutputStream with the given arguments used for configuration.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      aLineLength - The number of bytes after which to insert a line break, a line length of -1 does not insert any line breaks at all.
      aLineBreak - The line break chars to use.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes)
      Constructs a HexOutputStream with the given arguments used for configuration.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      aLineLength - The number of bytes after which to insert a line break, a line length of -1 does not insert any line breaks at all.
      aLineBreak - The line break chars to use.
      isPrefixBytes - When true, then 0x is prefixed to the HEX values.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, int aLineLength)
      Constructs a HexOutputStream with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      aLineLength - The number of bytes after which to insert a line break, a line length of -1 does not insert any line breaks at all.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes)
      Constructs a HexOutputStream with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      aLineLength - The number of bytes after which to insert a line break, a line length of -1 does not insert any line breaks at all.
      isPrefixBytes - When true, then 0x is prefixed to the HEX values.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, boolean isPrefixBytes, boolean isFlushLineBreak)
      Constructs a HexOutputStream with the given arguments used for configuration.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      isPrefixBytes - When true, then 0x is prefixed to the HEX values.
      isFlushLineBreak - When true, then a line break is also inserted upon a flush() operation.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes, boolean isFlushLineBreak)
      Constructs a HexOutputStream with the given arguments used for configuration.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      aLineLength - The number of bytes after which to insert a line break, a line length of -1 does not insert any line breaks at all.
      aLineBreak - The line break chars to use.
      isPrefixBytes - When true, then 0x is prefixed to the HEX values.
      isFlushLineBreak - When true, then a line break is also inserted upon a flush() operation.
    • HexOutputStream

      public HexOutputStream(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes, boolean isFlushLineBreak)
      Constructs a HexOutputStream with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.
      Parameters:
      aOutputStream - The OutputStream where to write the bytes converted to hexadecimal text to.
      aLineLength - The number of bytes after which to insert a line break, a line length of -1 does not insert any line breaks at all.
      isPrefixBytes - When true, then 0x is prefixed to the HEX values.
      isFlushLineBreak - When true, then a line break is also inserted upon a flush() operation.
  • Method Details