Here you can find the source of toString(byte[] b)
Parameter | Description |
---|---|
b | An array containing binary data |
public static String toString(byte[] b)
//package com.java2s; import java.io.*; public class Main { private static final String Base16 = "0123456789ABCDEF"; /**/*from ww w . j a v a 2 s .c o m*/ * Convert binary data to a hex-encoded String * @param b An array containing binary data * @return A String containing the encoded data */ public static String toString(byte[] b) { ByteArrayOutputStream os = new ByteArrayOutputStream(); for (int i = 0; i < b.length; i++) { short value = (short) (b[i] & 0xFF); byte high = (byte) (value >> 4); byte low = (byte) (value & 0xF); os.write(Base16.charAt(high)); os.write(Base16.charAt(low)); } return new String(os.toByteArray()); } }