Java Radian From toRadix16(byte[] source, int srcOffset, int len)

Here you can find the source of toRadix16(byte[] source, int srcOffset, int len)

Description

Convert an n-bit BIG-ENDIAN representation of a number into its hexadecimal form

License

Open Source License

Parameter

Parameter Description
source an array containing the n
srcOffset position in the source array where to start
len number of bytes to convert

Return

string of hexadecimal digits

Declaration

public static String toRadix16(byte[] source, int srcOffset, int len) 

Method Source Code

//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);
    }
}

Related

  1. toRadians(final double value)
  2. toRadians(float a)
  3. toRadians(int latitude)
  4. toRadians(Integer angdeg)
  5. toRadix16(byte[] source, int srcOffset, int len)
  6. toRadixPrefix(int radix)