Here you can find the source of byteToHexString(byte b)
public static String byteToHexString(byte b)
//package com.java2s; /* J_LZ_COPYRIGHT_BEGIN ******************************************************* * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. * * Use is subject to license terms. * * J_LZ_COPYRIGHT_END *********************************************************/ public class Main { /**//from w ww .jav a 2 s . c o m * @return hex representation of byte. */ public static String byteToHexString(byte b) { int left = (int) ((b & 0xf0) >> 4); int right = (int) (b & 0x0f); return Integer.toHexString(left) + Integer.toHexString(right); } }