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
ConstructorDescriptionHexOutputStream
(OutputStream aOutputStream) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, boolean isPrefixBytes) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, int aLineLength) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, int aLineLength, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, int aLineLength, String aLineBreak) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes) Constructs aHexOutputStream
with the given arguments used for configuration.HexOutputStream
(OutputStream aOutputStream, int aLineLength, String aLineBreak, boolean isPrefixBytes, boolean isFlushLineBreak) Constructs aHexOutputStream
with the given arguments used for configuration. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Constructor Details
-
HexOutputStream
Constructs aHexOutputStream
with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream
- TheOutputStream
where to write the bytes converted to hexadecimal text to.
-
HexOutputStream
Constructs aHexOutputStream
with the given arguments used for configuration.- Parameters:
aOutputStream
- TheOutputStream
where to write the bytes converted to hexadecimal text to.isPrefixBytes
- When true, then0x
is prefixed to the HEX values.
-
HexOutputStream
Constructs aHexOutputStream
with the given arguments used for configuration.- Parameters:
aOutputStream
- TheOutputStream
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 aHexOutputStream
with the given arguments used for configuration.- Parameters:
aOutputStream
- TheOutputStream
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, then0x
is prefixed to the HEX values.
-
HexOutputStream
Constructs aHexOutputStream
with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream
- TheOutputStream
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
Constructs aHexOutputStream
with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream
- TheOutputStream
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, then0x
is prefixed to the HEX values.
-
HexOutputStream
Constructs aHexOutputStream
with the given arguments used for configuration.- Parameters:
aOutputStream
- TheOutputStream
where to write the bytes converted to hexadecimal text to.isPrefixBytes
- When true, then0x
is 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 aHexOutputStream
with the given arguments used for configuration.- Parameters:
aOutputStream
- TheOutputStream
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, then0x
is 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 aHexOutputStream
with the given arguments used for configuration. The line break characters used are the ones used by the underlying operating system.- Parameters:
aOutputStream
- TheOutputStream
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, then0x
is prefixed to the HEX values.isFlushLineBreak
- When true, then a line break is also inserted upon aflush()
operation.
-
-
Method Details
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-