Here you can find the source of byteToHexString(byte b)
Parameter | Description |
---|---|
b | a parameter |
public static String byteToHexString(byte b)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013, 2015 Orange./*from w ww . ja v a 2 s .c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Victor PERRON, Antonin CHAZALET, Andre BOTTARO. *******************************************************************************/ public class Main { private static final char[] hexArray = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /** * @param b * @return byteToHexString */ public static String byteToHexString(byte b) { char[] hexChar = new char[2]; int v = b & 0xFF; hexChar[0] = hexArray[v >>> 4]; hexChar[1] = hexArray[v & 0x0F]; return new String(hexChar); } }