Here you can find the source of toHexStr(byte[] binary)
public static String toHexStr(byte[] binary)
//package com.java2s; /*!/*from ww w . ja v a 2s. co m*/ * mifmi-commons4j * https://github.com/mifmi/mifmi-commons4j * * Copyright (c) 2015 mifmi.org and other contributors * Released under the MIT license * https://opensource.org/licenses/MIT */ public class Main { public static String toHexStr(byte[] binary) { if (binary == null) { return null; } if (binary.length == 0) { return ""; } int len = binary.length; StringBuilder sb = new StringBuilder(len * 2); for (byte b : binary) { int high = ((b >>> 4) & 0xF); int low = (b & 0xF); if (high < 10) { sb.append((char) ('0' + high)); } else { sb.append((char) ('A' + (high - 10))); } if (low < 10) { sb.append((char) ('0' + low)); } else { sb.append((char) ('A' + (low - 10))); } } return sb.toString(); } }