|
||||||||||
| 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(OutputStream out)
Constructs a new HexOutputStream with a default width of 16 hex numbers (and corresponding ascii values) per line. |
|
HexOutputStream(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(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 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(OutputStream out)
out - the underlying outputstream to send the data to
public HexOutputStream(OutputStream out,
int width)
out - the underlying outputstream to send the data towidth - the number of hex numbers to print per line| Method Detail |
|---|
public void close()
close in interface Closeableclose in class FilterOutputStreampublic void flush()
flush in interface Flushableflush in class FilterOutputStreampublic void write(int b)
write in class FilterOutputStreampublic void write(byte[] buf)
write in class FilterOutputStream
public void write(byte[] buf,
int off,
int len)
write in class FilterOutputStreampublic 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)
IllegalArgumentException - if the specified base is not between [2, 36]public static final String toHex(byte[] buf)
public static void main(String[] args)
throws Exception
Usage: java HexOutputStreamoptions: -file filename or -data string
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||