Mega Code Archive

 
Categories / Java / File Input Output
 

Convert byte array to Hex string

public class Util {   public static String dumpHex(byte[] bytes) {     StringBuffer buf = new StringBuffer();     int aByte;     for (int i = 0; i < bytes.length; i++) {       aByte = bytes[i];       if (aByte < 0)         aByte += 0x100;       buf.append("[" + Integer.toString(aByte, 16) + "]");     }     return buf.toString();   } }