Here you can find the source of toHexString(byte[] ba, int offset, int length)
Parameter | Description |
---|---|
ba | Description of Parameter |
offset | Description of Parameter |
length | Description of Parameter |
public static String toHexString(byte[] ba, int offset, int length)
//package com.java2s; /*// w w w . j ava 2 s. c o m * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ public class Main { /** Field HEX_DIGITS */ private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * converts String to Hex String. Example: niko ->6E696B6F * * @param ba Description of Parameter * @param offset Description of Parameter * @param length Description of Parameter * @return Description of the Returned Value */ public static String toHexString(byte[] ba, int offset, int length) { char[] buf; buf = new char[length * 2]; for (int i = offset, j = 0, k; i < offset + length;) { k = ba[i++]; buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F]; buf[j++] = HEX_DIGITS[k & 0x0F]; } return new String(buf); } }