Here you can find the source of byteToHexDisplayString(byte[] b)
Parameter | Description |
---|---|
b | the source buffer. |
static String byteToHexDisplayString(byte[] b)
//package com.java2s; /*/* w w w . j a v a 2 s . c o m*/ * Microsoft JDBC Driver for SQL Server * * Copyright(c) Microsoft Corporation All rights reserved. * * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. */ public class Main { final static char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Converts byte array to a string representation of hex bytes for display purposes. * * @param b * the source buffer. * @return "hexized" string representation of bytes. */ static String byteToHexDisplayString(byte[] b) { if (null == b) return "(null)"; int hexVal; StringBuilder sb = new StringBuilder(b.length * 2 + 2); sb.append("0x"); for (byte aB : b) { hexVal = aB & 0xFF; sb.append(hexChars[(hexVal & 0xF0) >> 4]); sb.append(hexChars[(hexVal & 0x0F)]); } return sb.toString(); } }