hex Dump - Java java.lang

Java examples for java.lang:Hex

Description

hex Dump

Demo Code


//package com.java2s;

public class Main {
    public static String hexDump(byte[] bytes) {
        String dump = "";
        int max = Math.min(bytes.length, 32);
        for (int i = 0; i < max; i++) {
            String hex = Integer.toHexString(bytes[i] & 0xFF);
            if (hex.length() == 1) {
                hex = "0" + hex;
            }/*ww  w. ja v a 2 s  . c o  m*/
            dump += hex + " ";
        }
        return dump;
    }
}

Related Tutorials