public static String encodeBytesToString(byte bytes[]) {
    StringBuilder string = new StringBuilder(bytes.length * 2);
    for (int i = 0; i < bytes.length; i++) {
      // look up high nibble char
      string.append(hexChar[(bytes[i] & 0xf0) >>> 4]);
      // look up low nibble char
      string.append(hexChar[bytes[i] & 0x0f]);
    }
    return string.toString();
  }
public static String encodeBytesToString ( byte bytes [ ] ) { StringBuilder string = new StringBuilder ( bytes . length * 2 ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { string . append ( hexChar [ ( bytes [ i ] & 0xf0 ) > > > 4 ] ) ; string . append ( hexChar [ bytes [ i ] & 0x0f ] ) ; } return string . toString ( ) ; }
Takes a byte array and returns a hex string (00-FF) encoded two chars per byte.