Visualizador Hexadecimal em Java

No tempo vago resolvi criar um visualizador hexadecimal em Java para demonstrar algumas funcionalidades do printf e pra uma outra aplicação bacana que vou fazer para análise de conteúdo de arquivo.

A implementação é bem simples. O código é feito apenas dentro de uma classe e a formatação dos dados é simplificada com o uso do System.out.printf. Sinta-se a vontade para modificar ou exportar o resultado para uma String e utilizar em uma interface gráfica (recomendo utilizar o método String.format).

Ao executar o código, o arquivo é lido caractere a caractere (linha 28). A primeira coluna exibe o endereço em hexadecimal dos valores sendo exibidos utilizando um contador. O valor é preenchido com zeros à esquerda. Isso pode ser facilmente utilizando o printf com o parâmetro %08x, conforme podemos ver na linha 30 do código. Após isso exibimos o valor em hexadecimal com dois caracteres: %02x (linha 33). A último coluna exibe o conteúdo do caractere se ele for imprimível ou ponto (.) caso contrário (linha 34), conforme tabela ASCII (0x20 até 0x7e - http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters). Para mais informações sobre os parametros do printf e format consulte a API: http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax

package br.com.thiagovespa.hex.utils;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class HexView {

	public static final int LINE_SIZE = 16;

	private final static Logger logger = Logger.getLogger(HexView.class
			.getName());

	public static boolean printChar(int charToPrint) {
		if (charToPrint >= 0x20 && charToPrint <= 0x7e) { // Printable chars
			return true;
		}
		return false;
	}

	public static void showFileContent(File file) throws IOException {
		InputStream is = null;
		try {
			is = new FileInputStream(file);
			int r;
			int count = 0;
			StringBuffer charPrintBuffer = new StringBuffer("    ");
			while ((r = is.read()) != -1) {
				if (count % LINE_SIZE == 0) {
					System.out.printf("\n%08x   ", count);
				}
				count++;
				System.out.printf("%02x ", r);
				charPrintBuffer.append((printChar(r) ? (char) r : '.'));
				if (count % LINE_SIZE == 0) {
					System.out.print(charPrintBuffer);
					charPrintBuffer = new StringBuffer("    ");
				}
			}
			System.out
					.printf("%"
							+ (((LINE_SIZE - (count % LINE_SIZE)) * 3) + charPrintBuffer
									.length()) + "s", charPrintBuffer);
		} finally {
			if (is != null) {
				is.close();
			}
		}
		System.out.println();
	}

	public static void main(String[] args) {
		try {
			if (args.length <= 0) {
				System.out.println("Sintaxe: java "
						+ HexView.class.getName() + " arquivo");
			} else {
				showFileContent(new File(args[0]));
			}
		} catch (IOException ioe) {
			logger.log(Level.SEVERE, "Erro ao ler arquivo " + args[0], ioe);
		}
	}

}

Você pode aumentar os tamanhos das colunas alterando a constante LINE_SIZE.  Ao executar o código passando um arquivo texto como exemplo, você terá uma saída parecida com a seguinte:

00000000   4f 6c 68 61 20 6f 73 20 76 61 6c 6f 72 65 73 20     Olha os valores
00000010   65 6d 20 68 65 78 61 64 65 63 69 6d 61 6c 20 6e     em hexadecimal n
00000020   6f 20 62 6c 6f 67 20 64 6f 20 54 68 69 61 67 6f     o blog do Thiago
00000030   20 47 61 6c 62 69 61 74 74 69 20 56 65 73 70 61      Galbiatti Vespa
00000040   21 0a                                               !.

O mesmo código poderá ser executado para um arquivo binário. Por exemplo, executando para o .class dessa aplicação temos.:

00000000   ca fe ba be 00 00 00 32 00 9f 07 00 02 01 00 24     .......2.......$
00000010   62 72 2f 63 6f 6d 2f 74 68 69 61 67 6f 76 65 73     br/com/thiagoves
00000020   70 61 2f 68 65 78 2f 75 74 69 6c 73 2f 48 65 78     pa/hex/utils/Hex
00000030   56 69 65 77 07 00 04 01 00 10 6a 61 76 61 2f 6c     View......java/l
00000040   61 6e 67 2f 4f 62 6a 65 63 74 01 00 09 4c 49 4e     ang/Object...LIN
00000050   45 5f 53 49 5a 45 01 00 01 49 01 00 0d 43 6f 6e     E_SIZE...I...Con
00000060   73 74 61 6e 74 56 61 6c 75 65 03 00 00 00 10 01     stantValue......
00000070   00 06 6c 6f 67 67 65 72 01 00 1a 4c 6a 61 76 61     ..logger...Ljava
00000080   2f 75 74 69 6c 2f 6c 6f 67 67 69 6e 67 2f 4c 6f     /util/logging/Lo
00000090   67 67 65 72 3b 01 00 08 3c 63 6c 69 6e 69 74 3e     gger;...
000000a0   01 00 03 28 29 56 01 00 04 43 6f 64 65 0a 00 0f     ...()V...Code...
000000b0   00 11 07 00 10 01 00 0f 6a 61 76 61 2f 6c 61 6e     ........java/lan
000000c0   67 2f 43 6c 61 73 73 0c 00 12 00 13 01 00 07 67     g/Class........g
000000d0   65 74 4e 61 6d 65 01 00 14 28 29 4c 6a 61 76 61     etName...()Ljava
000000e0   2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b 0a 00 15     /lang/String;...
000000f0   00 17 07 00 16 01 00 18 6a 61 76 61 2f 75 74 69     ........java/uti
00000100   6c 2f 6c 6f 67 67 69 6e 67 2f 4c 6f 67 67 65 72     l/logging/Logger
00000110   0c 00 18 00 19 01 00 09 67 65 74 4c 6f 67 67 65     ........getLogge
00000120   72 01 00 2e 28 4c 6a 61 76 61 2f 6c 61 6e 67 2f     r...(Ljava/lang/
00000130   53 74 72 69 6e 67 3b 29 4c 6a 61 76 61 2f 75 74     String;)Ljava/ut
00000140   69 6c 2f 6c 6f 67 67 69 6e 67 2f 4c 6f 67 67 65     il/logging/Logge
00000150   72 3b 09 00 01 00 1b 0c 00 09 00 0a 01 00 0f 4c     r;.............L
00000160   69 6e 65 4e 75 6d 62 65 72 54 61 62 6c 65 01 00     ineNumberTable..
00000170   12 4c 6f 63 61 6c 56 61 72 69 61 62 6c 65 54 61     .LocalVariableTa
00000180   62 6c 65 01 00 06 3c 69 6e 69 74 3e 0a 00 03 00     ble.......
00000190   20 0c 00 1e 00 0c 01 00 04 74 68 69 73 01 00 26      ........this..&
000001a0   4c 62 72 2f 63 6f 6d 2f 74 68 69 61 67 6f 76 65     Lbr/com/thiagove
000001b0   73 70 61 2f 68 65 78 2f 75 74 69 6c 73 2f 48 65     spa/hex/utils/He
000001c0   78 56 69 65 77 3b 01 00 09 70 72 69 6e 74 43 68     xView;...printCh
000001d0   61 72 01 00 04 28 49 29 5a 01 00 0b 63 68 61 72     ar...(I)Z...char
000001e0   54 6f 50 72 69 6e 74 01 00 0d 53 74 61 63 6b 4d     ToPrint...StackM
000001f0   61 70 54 61 62 6c 65 01 00 0f 73 68 6f 77 46 69     apTable...showFi
00000200   6c 65 43 6f 6e 74 65 6e 74 01 00 11 28 4c 6a 61     leContent...(Lja
00000210   76 61 2f 69 6f 2f 46 69 6c 65 3b 29 56 01 00 0a     va/io/File;)V...
00000220   45 78 63 65 70 74 69 6f 6e 73 07 00 2b 01 00 13     Exceptions..+...
00000230   6a 61 76 61 2f 69 6f 2f 49 4f 45 78 63 65 70 74     java/io/IOExcept
00000240   69 6f 6e 07 00 2d 01 00 17 6a 61 76 61 2f 69 6f     ion..-...java/io
00000250   2f 46 69 6c 65 49 6e 70 75 74 53 74 72 65 61 6d     /FileInputStream
00000260   0a 00 2c 00 2f 0c 00 1e 00 28 07 00 31 01 00 16     ..,./....(..1...
00000270   6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67     java/lang/String
00000280   42 75 66 66 65 72 08 00 33 01 00 04 20 20 20 20     Buffer..3...
00000290   0a 00 30 00 35 0c 00 1e 00 36 01 00 15 28 4c 6a     ..0.5....6...(Lj
000002a0   61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b     ava/lang/String;
000002b0   29 56 09 00 38 00 3a 07 00 39 01 00 10 6a 61 76     )V..8.:..9...jav
000002c0   61 2f 6c 61 6e 67 2f 53 79 73 74 65 6d 0c 00 3b     a/lang/System..;
000002d0   00 3c 01 00 03 6f 75 74 01 00 15 4c 6a 61 76 61     .<...out...Ljava 
000002e0   2f 69 6f 2f 50 72 69 6e 74 53 74 72 65 61 6d 3b     /io/PrintStream; 
000002f0   08 00 3e 01 00 08 0a 25 30 38 78 20 20 20 0a 00     ..>....%08x   ..
00000300   40 00 42 07 00 41 01 00 11 6a 61 76 61 2f 6c 61     @.B..A...java/la
00000310   6e 67 2f 49 6e 74 65 67 65 72 0c 00 43 00 44 01     ng/Integer..C.D.
00000320   00 07 76 61 6c 75 65 4f 66 01 00 16 28 49 29 4c     ..valueOf...(I)L
00000330   6a 61 76 61 2f 6c 61 6e 67 2f 49 6e 74 65 67 65     java/lang/Intege
00000340   72 3b 0a 00 46 00 48 07 00 47 01 00 13 6a 61 76     r;..F.H..G...jav
00000350   61 2f 69 6f 2f 50 72 69 6e 74 53 74 72 65 61 6d     a/io/PrintStream
00000360   0c 00 49 00 4a 01 00 06 70 72 69 6e 74 66 01 00     ..I.J...printf..
00000370   3c 28 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72     <(Ljava/lang/Str
00000380   69 6e 67 3b 5b 4c 6a 61 76 61 2f 6c 61 6e 67 2f     ing;[Ljava/lang/
00000390   4f 62 6a 65 63 74 3b 29 4c 6a 61 76 61 2f 69 6f     Object;)Ljava/io
000003a0   2f 50 72 69 6e 74 53 74 72 65 61 6d 3b 08 00 4c     /PrintStream;..L
000003b0   01 00 05 25 30 32 78 20 0a 00 01 00 4e 0c 00 23     ...%02x ....N..#
000003c0   00 24 0a 00 30 00 50 0c 00 51 00 52 01 00 06 61     .$..0.P..Q.R...a
000003d0   70 70 65 6e 64 01 00 1b 28 43 29 4c 6a 61 76 61     ppend...(C)Ljava
000003e0   2f 6c 61 6e 67 2f 53 74 72 69 6e 67 42 75 66 66     /lang/StringBuff
000003f0   65 72 3b 0a 00 46 00 54 0c 00 55 00 56 01 00 05     er;..F.T..U.V...
00000400   70 72 69 6e 74 01 00 15 28 4c 6a 61 76 61 2f 6c     print...(Ljava/l
00000410   61 6e 67 2f 4f 62 6a 65 63 74 3b 29 56 0a 00 58     ang/Object;)V..X
00000420   00 5a 07 00 59 01 00 13 6a 61 76 61 2f 69 6f 2f     .Z..Y...java/io/
00000430   49 6e 70 75 74 53 74 72 65 61 6d 0c 00 5b 00 5c     InputStream..[.\
00000440   01 00 04 72 65 61 64 01 00 03 28 29 49 07 00 5e     ...read...()I..^
00000450   01 00 17 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72     ...java/lang/Str
00000460   69 6e 67 42 75 69 6c 64 65 72 08 00 60 01 00 01     ingBuilder..`...
00000470   25 0a 00 5d 00 35 0a 00 30 00 63 0c 00 64 00 5c     %..].5..0.c..d.\
00000480   01 00 06 6c 65 6e 67 74 68 0a 00 5d 00 66 0c 00     ...length..].f..
00000490   51 00 67 01 00 1c 28 49 29 4c 6a 61 76 61 2f 6c     Q.g...(I)Ljava/l
000004a0   61 6e 67 2f 53 74 72 69 6e 67 42 75 69 6c 64 65     ang/StringBuilde
000004b0   72 3b 08 00 69 01 00 01 73 0a 00 5d 00 6b 0c 00     r;..i...s..].k..
000004c0   51 00 6c 01 00 2d 28 4c 6a 61 76 61 2f 6c 61 6e     Q.l..-(Ljava/lan
000004d0   67 2f 53 74 72 69 6e 67 3b 29 4c 6a 61 76 61 2f     g/String;)Ljava/
000004e0   6c 61 6e 67 2f 53 74 72 69 6e 67 42 75 69 6c 64     lang/StringBuild
000004f0   65 72 3b 0a 00 5d 00 6e 0c 00 6f 00 13 01 00 08     er;..].n..o.....
00000500   74 6f 53 74 72 69 6e 67 0a 00 58 00 71 0c 00 72     toString..X.q..r
00000510   00 0c 01 00 05 63 6c 6f 73 65 0a 00 46 00 74 0c     .....close..F.t.
00000520   00 75 00 0c 01 00 07 70 72 69 6e 74 6c 6e 01 00     .u.....println..
00000530   04 66 69 6c 65 01 00 0e 4c 6a 61 76 61 2f 69 6f     .file...Ljava/io
00000540   2f 46 69 6c 65 3b 01 00 02 69 73 01 00 15 4c 6a     /File;...is...Lj
00000550   61 76 61 2f 69 6f 2f 49 6e 70 75 74 53 74 72 65     ava/io/InputStre
00000560   61 6d 3b 01 00 01 72 01 00 05 63 6f 75 6e 74 01     am;...r...count.
00000570   00 0f 63 68 61 72 50 72 69 6e 74 42 75 66 66 65     ..charPrintBuffe
00000580   72 01 00 18 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53     r...Ljava/lang/S
00000590   74 72 69 6e 67 42 75 66 66 65 72 3b 07 00 7f 01     tringBuffer;....
000005a0   00 0c 6a 61 76 61 2f 69 6f 2f 46 69 6c 65 07 00     ..java/io/File..
000005b0   81 01 00 13 6a 61 76 61 2f 6c 61 6e 67 2f 54 68     ....java/lang/Th
000005c0   72 6f 77 61 62 6c 65 01 00 04 6d 61 69 6e 01 00     rowable...main..
000005d0   16 28 5b 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74     .([Ljava/lang/St
000005e0   72 69 6e 67 3b 29 56 08 00 85 01 00 0e 53 69 6e     ring;)V......Sin
000005f0   74 61 78 65 3a 20 6a 61 76 61 20 08 00 87 01 00     taxe: java .....
00000600   0f 20 3c 6e 6f 6d 65 20 61 72 71 75 69 76 6f 3e     .
00000610   0a 00 46 00 89 0c 00 75 00 36 0a 00 7e 00 35 0a     ..F....u.6..~.5.
00000620   00 01 00 8c 0c 00 27 00 28 09 00 8e 00 90 07 00     ......'.(.......
00000630   8f 01 00 17 6a 61 76 61 2f 75 74 69 6c 2f 6c 6f     ....java/util/lo
00000640   67 67 69 6e 67 2f 4c 65 76 65 6c 0c 00 91 00 92     gging/Level.....
00000650   01 00 06 53 45 56 45 52 45 01 00 19 4c 6a 61 76     ...SEVERE...Ljav
00000660   61 2f 75 74 69 6c 2f 6c 6f 67 67 69 6e 67 2f 4c     a/util/logging/L
00000670   65 76 65 6c 3b 08 00 94 01 00 14 45 72 72 6f 20     evel;......Erro
00000680   61 6f 20 6c 65 72 20 61 72 71 75 69 76 6f 20 0a     ao ler arquivo .
00000690   00 15 00 96 0c 00 97 00 98 01 00 03 6c 6f 67 01     ............log.
000006a0   00 43 28 4c 6a 61 76 61 2f 75 74 69 6c 2f 6c 6f     .C(Ljava/util/lo
000006b0   67 67 69 6e 67 2f 4c 65 76 65 6c 3b 4c 6a 61 76     gging/Level;Ljav
000006c0   61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b 4c 6a     a/lang/String;Lj
000006d0   61 76 61 2f 6c 61 6e 67 2f 54 68 72 6f 77 61 62     ava/lang/Throwab
000006e0   6c 65 3b 29 56 01 00 04 61 72 67 73 01 00 13 5b     le;)V...args...[
000006f0   4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e     Ljava/lang/Strin
00000700   67 3b 01 00 03 69 6f 65 01 00 15 4c 6a 61 76 61     g;...ioe...Ljava
00000710   2f 69 6f 2f 49 4f 45 78 63 65 70 74 69 6f 6e 3b     /io/IOException;
00000720   01 00 0a 53 6f 75 72 63 65 46 69 6c 65 01 00 0c     ...SourceFile...
00000730   48 65 78 56 69 65 77 2e 6a 61 76 61 00 21 00 01     HexView.java.!..
00000740   00 03 00 00 00 02 00 19 00 05 00 06 00 01 00 07     ................
00000750   00 00 00 02 00 08 00 1a 00 09 00 0a 00 00 00 05     ................
00000760   00 08 00 0b 00 0c 00 01 00 0d 00 00 00 38 00 01     .............8..
00000770   00 00 00 00 00 0c 12 01 b6 00 0e b8 00 14 b3 00     ................
00000780   1a b1 00 00 00 02 00 1c 00 00 00 12 00 04 00 00     ................
00000790   00 0b 00 02 00 0c 00 05 00 0b 00 0b 00 07 00 1d     ................
000007a0   00 00 00 02 00 00 00 01 00 1e 00 0c 00 01 00 0d     ................
000007b0   00 00 00 2f 00 01 00 01 00 00 00 05 2a b7 00 1f     .../........*...
000007c0   b1 00 00 00 02 00 1c 00 00 00 06 00 01 00 00 00     ................
000007d0   07 00 1d 00 00 00 0c 00 01 00 00 00 05 00 21 00     ..............!.
000007e0   22 00 00 00 09 00 23 00 24 00 01 00 0d 00 00 00     ".....#.$.......
000007f0   4b 00 02 00 01 00 00 00 10 1a 10 20 a1 00 0b 1a     K.......... ....
00000800   10 7e a3 00 05 04 ac 03 ac 00 00 00 03 00 1c 00     .~..............
00000810   00 00 0e 00 03 00 00 00 0f 00 0c 00 10 00 0e 00     ................
00000820   12 00 1d 00 00 00 0c 00 01 00 00 00 10 00 25 00     ..............%.
00000830   06 00 00 00 26 00 00 00 03 00 01 0e 00 09 00 27     ....&..........'
00000840   00 28 00 02 00 29 00 00 00 04 00 01 00 2a 00 0d     .(...).......*..
00000850   00 00 02 2b 00 06 00 06 00 00 00 d7 01 4c bb 00     ...+.........L..
00000860   2c 59 2a b7 00 2e 4c 03 3e bb 00 30 59 12 32 b7     ,Y*...L.>..0Y.2.
00000870   00 34 3a 04 a7 00 63 1d 10 10 70 9a 00 17 b2 00     .4:...c...p.....
00000880   37 12 3d 04 bd 00 03 59 03 1d b8 00 3f 53 b6 00     7.=....Y....?S..
00000890   45 57 84 03 01 b2 00 37 12 4b 04 bd 00 03 59 03     EW.....7.K....Y.
000008a0   1c b8 00 3f 53 b6 00 45 57 19 04 1c b8 00 4d 99     ...?S..EW.....M.
000008b0   00 08 1c 92 a7 00 05 10 2e b6 00 4f 57 1d 10 10     ...........OW...
000008c0   70 9a 00 16 b2 00 37 19 04 b6 00 53 bb 00 30 59     p.....7....S..0Y
000008d0   12 32 b7 00 34 3a 04 2b b6 00 57 59 3d 02 a0 ff     .2..4:.+..WY=...
000008e0   99 b2 00 37 bb 00 5d 59 12 5f b7 00 61 10 10 1d     ...7..]Y._..a...
000008f0   10 10 70 64 06 68 19 04 b6 00 62 60 b6 00 65 12     ..pd.h....b`..e.
00000900   68 b6 00 6a b6 00 6d 04 bd 00 03 59 03 19 04 53     h..j..m....Y...S
00000910   b6 00 45 57 a7 00 10 3a 05 2b c6 00 07 2b b6 00     ..EW...:.+...+..
00000920   70 19 05 bf 2b c6 00 07 2b b6 00 70 b2 00 37 b6     p...+...+..p..7.
00000930   00 73 b1 00 01 00 02 00 bb 00 bb 00 00 00 03 00     .s..............
00000940   1c 00 00 00 7e 00 1f 00 00 00 16 00 02 00 18 00     ....~...........
00000950   0b 00 1a 00 0d 00 1b 00 18 00 1c 00 1b 00 1d 00     ................
00000960   22 00 1e 00 36 00 20 00 39 00 21 00 4d 00 22 00     "...6. .9.!.M.".
00000970   61 00 23 00 68 00 24 00 70 00 25 00 7b 00 1c 00     a.#.h.$.p.%.{...
00000980   85 00 28 00 88 00 29 00 91 00 2a 00 9c 00 2b 00     ..(...)...*...+.
00000990   9f 00 2a 00 a3 00 2b 00 a8 00 29 00 b1 00 2b 00     ..*...+...)...+.
000009a0   b4 00 29 00 bb 00 2c 00 bd 00 2d 00 c1 00 2e 00     ..)...,...-.....
000009b0   c5 00 30 00 c8 00 2d 00 cc 00 2e 00 d0 00 31 00     ..0...-.......1.
000009c0   d6 00 32 00 1d 00 00 00 3e 00 06 00 00 00 d7 00     ..2.....>.......
000009d0   76 00 77 00 00 00 02 00 d5 00 78 00 79 00 01 00     v.w.......x.y...
000009e0   1b 00 60 00 7a 00 06 00 02 00 81 00 3a 00 7a 00     ..`.z.......:.z.
000009f0   06 00 02 00 0d 00 ae 00 7b 00 06 00 03 00 18 00     ........{.......
00000a00   a3 00 7c 00 7d 00 04 00 26 00 00 00 72 00 09 ff     ..|.}...&...r...
00000a10   00 1b 00 05 07 00 7e 07 00 58 01 01 07 00 30 00     ......~..X....0.
00000a20   00 1a 64 07 00 30 ff 00 01 00 05 07 00 7e 07 00     ..d..0.......~..
00000a30   58 01 01 07 00 30 00 02 07 00 30 01 ff 00 1d 00     X....0....0.....
00000a40   05 07 00 7e 07 00 58 00 01 07 00 30 00 00 ff 00     ...~..X....0....
00000a50   3f 00 02 07 00 7e 07 00 58 00 01 07 00 80 ff 00     ?....~..X.......
00000a60   09 00 06 07 00 7e 07 00 58 00 00 00 07 00 80 00     .....~..X.......
00000a70   00 ff 00 02 00 02 07 00 7e 07 00 58 00 00 07 00     ........~..X....
00000a80   09 00 82 00 83 00 01 00 0d 00 00 00 bc 00 05 00     ................
00000a90   02 00 00 00 55 2a be 9d 00 25 b2 00 37 bb 00 5d     ....U*...%..7..]
00000aa0   59 12 84 b7 00 61 12 01 b6 00 0e b6 00 6a 12 86     Y....a.......j..
00000ab0   b6 00 6a b6 00 6d b6 00 88 a7 00 30 bb 00 7e 59     ..j..m.....0..~Y
00000ac0   2a 03 32 b7 00 8a b8 00 8b a7 00 20 4c b2 00 1a     *.2........ L...
00000ad0   b2 00 8d bb 00 5d 59 12 93 b7 00 61 2a 03 32 b6     .....]Y....a*.2.
00000ae0   00 6a b6 00 6d 2b b6 00 95 b1 00 01 00 00 00 34     .j..m+.........4
00000af0   00 37 00 2a 00 03 00 1c 00 00 00 22 00 08 00 00     .7.*......."....
00000b00   00 36 00 05 00 37 00 11 00 38 00 21 00 37 00 27     .6...7...8.!.7.'
00000b10   00 3a 00 37 00 3c 00 38 00 3d 00 54 00 3f 00 1d     .:.7.<.8.=.T.?..
00000b20   00 00 00 16 00 02 00 00 00 55 00 99 00 9a 00 00     .........U......
00000b30   00 38 00 1c 00 9b 00 9c 00 01 00 26 00 00 00 09     .8.........&....
00000b40   00 04 27 0c 42 07 00 2a 1c 00 01 00 9d 00 00 00     ..'.B..*........
00000b50   02 00 9e                                            ...

Repare que o código em hexadecimal para qualquer classe em Java é: CAFE BABE. Olhe nos primeiros caracteres 😀

Qualquer sugestão é bem vinda!

Sobre: Thiago Galbiatti Vespa

Thiago Galbiatti Vespa é mestre em Ciências da Computação e Matemática Computacional pela USP e bacharel em Ciências da Computação pela UNESP. Coordenador de projetos do JavaNoroeste, membro do JCP (Java Community Process), consultor Oracle, arquiteto de software de empresas de médio e grande porte, palestrante de vários eventos e colaborador de projetos open source. Possui as certificações: Oracle Certified Master, Java EE 5 Enterprise Architect – Step 1, 2 and 3; Oracle WebCenter Portal 11g Certified Implementation Specialist; Oracle Service Oriented Architecture Infrastructure Implementation Certified Expert; Oracle Certified Professional, Java EE 5 Web Services Developer; Oracle Certified Expert, NetBeans Integrated Development Environment 6.1 Programmer; Oracle Certified Professional, Java Programmer; Oracle Certified Associate, Java SE 5/SE 6