Here you can find the source of byteToHexString(byte value)
public static String byteToHexString(byte value)
//package com.java2s; /*//from w ww . j av a2 s . c o m * Copyright 2004,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static String byteToHexString(byte value) { String temp = null; switch ((value & 0xF0) >> 4) { case 0: temp = "0"; break; case 1: temp = "1"; break; case 2: temp = "2"; break; case 3: temp = "3"; break; case 4: temp = "4"; break; case 5: temp = "5"; break; case 6: temp = "6"; break; case 7: temp = "7"; break; case 8: temp = "8"; break; case 9: temp = "9"; break; case 10: temp = "A"; break; case 11: temp = "B"; break; case 12: temp = "C"; break; case 13: temp = "D"; break; case 14: temp = "E"; break; case 15: temp = "F"; break; } switch ((value & 0x0F)) { case 0: temp += "0"; break; case 1: temp += "1"; break; case 2: temp += "2"; break; case 3: temp += "3"; break; case 4: temp += "4"; break; case 5: temp += "5"; break; case 6: temp += "6"; break; case 7: temp += "7"; break; case 8: temp += "8"; break; case 9: temp += "9"; break; case 10: temp += "A"; break; case 11: temp += "B"; break; case 12: temp += "C"; break; case 13: temp += "D"; break; case 14: temp += "E"; break; case 15: temp += "F"; break; } return temp; } }