Here you can find the source of toRadix16(byte[] source, int srcOffset, int len)
Parameter | Description |
---|---|
source | an array containing the n |
srcOffset | position in the source array where to start |
len | number of bytes to convert |
public static String toRadix16(byte[] source, int srcOffset, int len)
//package com.java2s; /**// www .ja v a2 s . c o m * Copyright (C) 2015 Michal Harish * <p/> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { private static final String HEX = "0123456789abcdef"; /** * Convert an n-bit BIG-ENDIAN representation of a number into its hexadecimal form * @param source an array containing the n * @param srcOffset position in the source array where to start * @param len number of bytes to convert * @return string of hexadecimal digits */ public static String toRadix16(byte[] source, int srcOffset, int len) { char[] hex = new char[len * 2]; for (int j = 0; j < len; j++) { int b = source[j + srcOffset] & 0xFF; hex[j * 2] = HEX.charAt(b >>> 4); hex[j * 2 + 1] = HEX.charAt(b & 0x0F); } return new String(hex); } }