Class HexOutputStream
java.lang.Object
java.io.OutputStream
org.refcodes.io.HexOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
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 Summary
ConstructorsConstructorDescriptionHexOutputStream(OutputStream aOutputStream) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, boolean isPrefixBytes) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, int aLineLength) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes) Constructs aHexOutputStreamwith the given arguments used for configuration.HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStreamwith the given arguments used for configuration. -
Method Summary
Methods inherited from class OutputStream
nullOutputStream, write, write
-
Constructor Details
-
HexOutputStream
Constructs aHexOutputStreamwith the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream- TheOutputStreamwhere to write the bytes converted to hexadecimal text to.
-
HexOutputStream
Constructs aHexOutputStreamwith the given arguments used for configuration.- Parameters:
aOutputStream- TheOutputStreamwhere to write the bytes converted to hexadecimal text to.isPrefixBytes- When true, then0xis prefixed to the HEX values.
-
HexOutputStream
Constructs aHexOutputStreamwith the given arguments used for configuration.- Parameters:
aOutputStream- TheOutputStreamwhere 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 aHexOutputStreamwith the given arguments used for configuration.- Parameters:
aOutputStream- TheOutputStreamwhere 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, then0xis prefixed to the HEX values.
-
HexOutputStream
Constructs aHexOutputStreamwith the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream- TheOutputStreamwhere 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
Constructs aHexOutputStreamwith the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream- TheOutputStreamwhere 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, then0xis prefixed to the HEX values.
-
HexOutputStream
Constructs aHexOutputStreamwith the given arguments used for configuration.- Parameters:
aOutputStream- TheOutputStreamwhere to write the bytes converted to hexadecimal text to.isPrefixBytes- When true, then0xis prefixed to the HEX values.isFlushLineBreak- When true, then a line break is also inserted upon aflush()operation.
-
HexOutputStream
public HexOutputStream(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStreamwith the given arguments used for configuration.- Parameters:
aOutputStream- TheOutputStreamwhere 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, then0xis prefixed to the HEX values.isFlushLineBreak- When true, then a line break is also inserted upon aflush()operation.
-
HexOutputStream
public HexOutputStream(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStreamwith the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream- TheOutputStreamwhere 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, then0xis prefixed to the HEX values.isFlushLineBreak- When true, then a line break is also inserted upon aflush()operation.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-