Here you can find the source of byteToHexString(byte value)
Parameter | Description |
---|---|
value | Byte to convert to hex string. |
public static String byteToHexString(byte value)
//package com.java2s; /**/*from w ww. j av a2 s .co m*/ * Copyright (c) 2014-2016 Digi International Inc., * All rights not expressly granted are reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 * ======================================================================= */ public class Main { private static final String HEXES = "0123456789ABCDEF"; /** * Converts the given byte into an hex string. * * @param value Byte to convert to hex string. * * @return Converted byte to hex string. */ public static String byteToHexString(byte value) { final StringBuilder hex = new StringBuilder(2); byte b = value; hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))); return hex.toString(); } }