Here you can find the source of byteToHexChars(byte value)
Parameter | Description |
---|---|
value | byte value |
public static char[] byteToHexChars(byte value)
//package com.java2s; /*/*from w ww . ja v a2s . c om*/ * Copyright (C) ExBin Project * * 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 final char[] UPPER_HEX_CODES = "0123456789ABCDEF" .toCharArray(); /** * Converts byte value to sequence of hexadecimal characters. * * @param value byte value * @return sequence of two hexadecimal chars with upper case */ public static char[] byteToHexChars(byte value) { char[] result = new char[2]; byteToHexChars(result, value); return result; } /** * Converts byte value to sequence of two hexadecimal characters. * * @param target target char array * @param value byte value */ public static void byteToHexChars(char[] target, byte value) { target[0] = UPPER_HEX_CODES[(value >> 4) & 15]; target[1] = UPPER_HEX_CODES[value & 15]; } }