Java Hex Calculate toHexString(byte b[])

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

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte b[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String toHexString(byte b[]) {
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            String plainText = Integer.toHexString(0xff & b[i]);
            if (plainText.length() < 2)
                plainText = "0" + plainText;
            hexString.append(plainText);
        }//from  w ww . j ava  2 s.  c  om

        return hexString.toString();
    }

    public static String toHexString(byte b) {
        String plainText = Integer.toHexString(0xff & b);
        if (plainText.length() < 2)
            plainText = "0" + plainText;
        return plainText;
    }
}

Related

  1. toHexString(byte b)
  2. toHexString(byte b)
  3. toHexString(byte b)
  4. toHexString(byte b)
  5. toHexString(byte b)
  6. toHexString(byte b[])
  7. toHexString(byte b[])
  8. toHexString(byte b[])
  9. toHexString(byte buffer[])