Here you can find the source of toHex(byte b)
Parameter | Description |
---|---|
b | the byte value to convert |
b
as a pair of hexadecimal digits.
public static String toHex(byte b)
//package com.java2s; /*/*from www. j a v a 2s . c om*/ * Copyright 2006 Helsinki Institute for Information Technology * * This file is a part of Fuego middleware. Fuego middleware is free software; you can redistribute * it and/or modify it under the terms of the MIT license, included as the file MIT-LICENSE in the * Fuego middleware source distribution. If you did not receive the MIT license with the * distribution, write to the Fuego Core project at fuego-core-users@hoslab.cs.helsinki.fi. */ public class Main { private final static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Convert a byte to its hexadecimal representation. * @param b * the byte value to convert * @return the representation of <code>b</code> as a pair of hexadecimal digits. */ public static String toHex(byte b) { return (new Character(hexDigits[(b & 0xF0) >> 4])).toString() + hexDigits[b & 0x0F]; } }