Here you can find the source of byteToHexString(int b)
public static String byteToHexString(int b)
//package com.java2s; // Licensed under the Academic Free License version 3.0 public class Main { /**/*from www. j a v a 2 s .co m*/ * @return byte to two character hex string. */ public static String byteToHexString(int b) { String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) return "0" + s; else return s; } /** * Return hex string of bytes. */ public static String toHexString(byte[] b) { StringBuffer s = new StringBuffer(); for (int i = 0; i < b.length; ++i) s.append(byteToHexString(b[i])); return s.toString(); } }