(byte[] data)
| 9 | |
| 10 | public class Hex { |
| 11 | public static String format(byte[] data) { |
| 12 | StringBuilder result = new StringBuilder(); |
| 13 | int n = 0; |
| 14 | for(byte b : data) { |
| 15 | if(n % 16 == 0) |
| 16 | result.append(String.format("%05X: ", n)); |
| 17 | result.append(String.format("%02X ", b)); |
| 18 | n++; |
| 19 | if(n % 16 == 0) result.append("\n"); |
| 20 | } |
| 21 | result.append("\n"); |
| 22 | return result.toString(); |
| 23 | } |
| 24 | public static void |
| 25 | main(String[] args) throws Exception { |
| 26 | if(args.length == 0) |