|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
fc.io.HexOutputStream
public final class HexOutputStream
Writes supplied bytes in hex/ascii form. Useful for hex dumps and debugging. Each write(..) method call is independent of previous invokations and prints data seperately from previous lines. This stream can also optionally print in other bases instead of hex.
In addition to it's streamy goodness, this class also provided some misc.
static utility functions such as toHex(int)
Constructor Summary | |
---|---|
HexOutputStream(java.io.OutputStream out)
Constructs a new HexOutputStream with a default width of 16 hex numbers (and corresponding ascii values) per line. |
|
HexOutputStream(java.io.OutputStream out,
int width)
Constructs a new HexOutputStream with the specified column width. |
Method Summary | |
---|---|
void |
close()
Be careful with this call, if the underlying stream is say, System.out, then calling this method will close System.out |
void |
flush()
|
static void |
main(java.lang.String[] args)
Unit Test: |
void |
setAutoFlush(boolean val)
Sets this stream to flush it's contents after every write statement. |
void |
setBase(int base)
Shows output in the specified base (instead of the default hex). |
void |
showLineNumbers(boolean val)
true/false enables or disables showing line numbers at the beginning of each line, if there is more than 1 line in the output. |
static java.lang.String |
toHex(byte[] buf)
Utility method to convert a byte buffer to a hexadecimal string. |
void |
write(byte[] buf)
|
void |
write(byte[] buf,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HexOutputStream(java.io.OutputStream out)
out
- the underlying outputstream to send the data topublic HexOutputStream(java.io.OutputStream out, int width)
out
- the underlying outputstream to send the data towidth
- the number of hex numbers to print per lineMethod Detail |
---|
public void close()
close
in interface java.io.Closeable
close
in class java.io.FilterOutputStream
public void flush()
flush
in interface java.io.Flushable
flush
in class java.io.FilterOutputStream
public void write(int b)
write
in class java.io.FilterOutputStream
public void write(byte[] buf)
write
in class java.io.FilterOutputStream
public void write(byte[] buf, int off, int len)
write
in class java.io.FilterOutputStream
public void setAutoFlush(boolean val)
public void showLineNumbers(boolean val)
public void setBase(int base)
base
- the base to show each byte in. Must be between
2 and 36 (inclusive)
java.lang.IllegalArgumentException
- if the specified base is not between [2, 36]public static final java.lang.String toHex(byte[] buf)
public static void main(java.lang.String[] args) throws java.lang.Exception
Usage: java HexOutputStreamoptions: -file filename or -data string
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |