Java Reference
In-Depth Information
pendedtothestring.(AlthoughJavaprovidesthe java.util.Formatter
classtohandlethistask, toHexStr() willhavetosufficefornowbecauseI
don't discuss Formatter until Appendix C.)
writeStr() writes a string of 8-bit characters to the file output stream.
Ordinarily, you would not create such a method because it ignores different
character sets (discussed later inthis chapter). However,character sets are not
an issue with this example.
Aftercompilingthislisting( javac DumpFileInHex.java ),supposeyouwant
to create a hexadecimal representation of the resulting DumpFileInHex.class
file. You can accomplish this task by executing java DumpFileInHex
DumpFileInHex.class . If all goes well, this command line creates a
DumpFileInHex.class.hex file. The first part of this file is shown below:
00000000 ca fe ba be 00 00 00 33 00 88 0a 00 29 00 42 09
.......3....).B.
00000010 00 43 00 44 08 00 45 0a 00 46 00 47 07 00 48 0a
.C.D..E..F.G..H.
00000020 00 05 00 42 0a 00 05 00 49 08 00 4a 0a 00 05 00
...B....I..J....
00000030 4b 07 00 4c 0a 00 0a 00 4d 07 00 4e 0a 00 0c 00
K..L....M..N....
00000040 4d 07 00 4f 0a 00 0e 00 42 0a 00 0a 00 50 0a 00
M..O....B....P..
00000050 28 00 51 0a 00 28 00 52 0a 00 0c 00 53 0a 00 0e
(.Q..(.R....S...
00000060 00 54 0a 00 0e 00 4b 09 00 28 00 55 0a 00 0e 00
.T....K..(.U....
00000070 56 0a 00 0e 00 57 08 00 58 0a 00 0c 00 59 07 00
V....W..X....Y..
00000080 5a 0a 00 1b 00 5b 0a 00 0a 00 59 07 00 5c 08 00
Z....[....Y..\..
00000090 5d 0a 00 1e 00 5e 0a 00 5f 00 60 0a 00 0e 00 4d
]....^.._.`....M
000000a0 0a 00 0e 00 61 0a 00 62 00 57 0a 00 62 00 63 08
....a..b.W..b.c.
000000b0 00 64 0a 00 43 00 65 07 00 66 07 00 67 01 00 0e
.d..C.e..f..g...
Search WWH ::




Custom Search