Here you can find the source of toHex(byte b)
public static String toHex(byte b)
//package com.java2s; // * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * public class Main { final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); public static String toHex(byte b) { char[] c = new char[2]; int v = b & 0xFF; c[0] = hexArray[v >>> 4]; c[1] = hexArray[v & 0x0F];//from ww w . ja v a 2 s . c o m return new String(c); } }