23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

}<br />

<strong>Java</strong> I/O<br />

if (hex >= 16) System.out.print(Integer.toHexString(hex) + " ");<br />

else System.out.print("0" + Integer.toHexString(hex) + " ");<br />

}<br />

System.out.println();<br />

}<br />

catch (<strong>IO</strong>Exception e) {System.err.println(e);}<br />

finally {<br />

try {<br />

if (fin != null) fin.close();<br />

}<br />

catch (<strong>IO</strong>Exception e) { }<br />

}<br />

When FileDumper is used to dump its own .class file in hexadecimal format, it produces the<br />

following:<br />

D:\JAVA\ioexamples\04>java FileDumper -h FileDumper.class<br />

ca fe ba be 00 03 00 2d 00 7e 03 00 00 00 00 03 00 00 00 01 03 00 00 00<br />

02 08 00 43 08 00 44 08 00 52 08 00 53 08 00 54 08 00 55 08 00 56 08 00<br />

63 07 00 5c 07 00 66 07 00 6d 07 00 6e 07 00 6f 07 00 70 07 00 71 07 00<br />

In later chapters, I'll add a graphical user interface and many more possible interpretations of<br />

the data in the file, including floating-point, big- and little-endian integer, and various text<br />

encodings.<br />

59

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!