public static String toHex(final byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (final byte b : bytes) {
            String s = Integer.toHexString(0xff & b);

            if (s.length() < 2) {
                sb.append("0");
            }
            sb.append(s);
        }
        return sb.toString();
    }
public static String toHex(final byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (final byte b : bytes) {
            String s = Integer.toHexString(0xff & b);

            if (s.length() < 2) {
                sb.append("0");
            }
            sb.append(s);
        }
        return sb.toString();
    }
public static String toHex ( final byte [ ] bytes ) { StringBuilder sb = new StringBuilder ( ) ; for ( final byte b : bytes ) { String s = Integer . toHexString ( 0xff & b ) ; if ( s . length ( ) < 2 ) { sb . append ( "0" ) ; } sb . append ( s ) ; } return sb . toString ( ) ; }
Converts the given byte buffer to a hexadecimal string using {@link java.lang.Integer#toHexString(int)}.

@param bytes the bytes to convert to hex
@return a String containing the hex representation of the given bytes.
Converts the given byte buffer to a hexadecimal string using { @link java . lang . Integer#toHexString ( int ) } .