Java Hex Print printHex(byte[] b)

Here you can find the source of printHex(byte[] b)

Description

print Hex

License

Open Source License

Declaration

public static String printHex(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static String printHex(byte[] b) {
        StringBuffer res = new StringBuffer();
        StringBuffer t, t1;//w  ww .java2s  . c om

        for (int i = 0; i < b.length; i++) {
            t = new StringBuffer(Integer.toHexString(b[i]));
            if (t.length() > 2) {
                t1 = new StringBuffer();
                t1.append(t.charAt(t.length() - 2));
                t1.append(t.charAt(t.length() - 1));
                t = t1;
            }
            res.append(t);
        }
        return res.toString();
    }
}

Related

  1. printHex(byte b)
  2. printHex(byte[] array)
  3. printHex(byte[] array, int offset, int len)
  4. printHex(byte[] bytes)
  5. printHex(byte[] bytes)
  6. printHex(byte[] data)
  7. printHex(byte[] field, int start, int len)