Here you can find the source of bytesToHex(byte[] bytes)
public static String bytesToHex(byte[] bytes)
//package com.java2s; /*/* w ww .ja v a 2 s . co m*/ * BioJava development code * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/copyleft/lesser.html * * Copyright for this code is held jointly by the individual * authors. These should be listed in @author doc comments. * * For more information on the BioJava project and its aims, * or to join the biojava-l mailing list, visit the home page * at: * * http://www.biojava.org/ * * Created on Nov 4, 2016 * Author: blivens * */ public class Main { final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); public static String bytesToHex(byte[] bytes) { return bytesToHex(bytes, bytes.length); } public static String bytesToHex(byte[] bytes, int len) { char[] hexChars = new char[len * 3]; for (int j = 0; j < len; j++) { int v = bytes[j] & 0xFF; hexChars[j * 3] = hexArray[v >>> 4]; hexChars[j * 3 + 1] = hexArray[v & 0x0F]; hexChars[j * 3 + 2] = ' '; } return new String(hexChars); } }