Here you can find the source of dumpHex(byte[] data, int offset, int length)
Parameter | Description |
---|---|
data | The RAW bytes. |
public static String dumpHex(byte[] data, int offset, int length)
//package com.java2s; //License from project: Open Source License public class Main { private static final char[] HEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /**//from w w w .jav a 2s . c o m * Returns the RAW bytes as hexadecimal string. * This method is used for debugging. * * @param data The RAW bytes. * @return The hexadecimal string. */ public static String dumpHex(byte[] data, int offset, int length) { char[] hex = new char[2 * length]; for (int i = 0; i < length; ++i) { final int b = data[offset + i] & 0xFF; hex[2 * i + 0] = HEX[b >>> 4]; hex[2 * i + 1] = HEX[b & 0x0F]; } return new String(hex); } public static String dumpHex(byte[] data) { return data != null ? dumpHex(data, 0, data.length) : "null"; } /** * Returns the integer as hexadecimal string. * * @param val The integer value. * @param width The number of characters to dump. * @return The hexadecimal string. */ public static String dumpHex(long val, int width) { char[] hex = new char[width]; for (int i = 0; i < width; ++i) { final long b = (val >>> ((width - 1 - i) * 4)); hex[i] = HEX[(int) b & 0x0F]; } return new String(hex); } }