Java Hex Calculate toHexStringUpperCase(byte[] b)

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

Description

to Hex String Upper Case

License

Apache License

Declaration

public static String toHexStringUpperCase(byte[] b) 

Method Source Code

//package com.java2s;
// Licensed to the Apache Software Foundation (ASF) under one

public class Main {
    private static final char[] hexCharsUpperCase = { '0', '1', '2', '3',
            '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

    public static String toHexStringUpperCase(byte[] b) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            sb.append(hexCharsUpperCase[(int) (((int) b[i] >> 4) & 0x0f)]);
            sb.append(hexCharsUpperCase[(int) (((int) b[i]) & 0x0f)]);
        }//from w  w w. ja  va 2s.  co m
        return sb.toString();
    }
}

Related

  1. toHexString0x(byte[] byteArray)
  2. toHexString2(int i)
  3. toHexString3(byte aByte)
  4. toHexStringBE(char[] array)
  5. toHexStringLE(byte n)
  6. toHexTable(byte[] byteSrc, int lengthOfLine)
  7. toHexText(byte[] bytes, int length)
  8. toHexUtil(int n)
  9. toHexValue(int number)