/** * Returns a hex string of the given byte. */ public static String getString(byte b) { char[] chars = new char[]{HEX_CHARS[getHighNibble(b)], HEX_CHARS[getLowNibble(b)]}; return new String(chars); }
/** * Writes the given byte as hex value to the given output stream. * @param b the byte to be written * @param output the output stream to be written to * @throws IOException exception if anything went wrong */ public static void writeHexByte(byte b, OutputStream output) throws IOException { output.write(HEX_BYTES[getHighNibble(b)]); output.write(HEX_BYTES[getLowNibble(b)]); }
/** * Returns a hex string of the given byte array. */ public static String getString(byte[] bytes) { StringBuilder string = new StringBuilder(bytes.length * 2); for (byte b : bytes) { string.append(HEX_CHARS[getHighNibble(b)]).append(HEX_CHARS[getLowNibble(b)]); } return string.toString(); }
/** * Returns the bytes corresponding to the ASCII hex encoding of the given byte. */ public static byte[] getBytes(byte b) { return new byte[]{HEX_BYTES[getHighNibble(b)], HEX_BYTES[getLowNibble(b)]}; }
/** * Returns the bytes corresponding to the ASCII hex encoding of the given bytes. */ public static byte[] getBytes(byte[] bytes) { byte[] asciiBytes = new byte[bytes.length*2]; for(int i=0; i< bytes.length; i++) { asciiBytes[i*2] = HEX_BYTES[getHighNibble(bytes[i])]; asciiBytes[i*2+1] = HEX_BYTES[getLowNibble(bytes[i])]; } return asciiBytes; }
/** * Returns a hex string of the given byte array. */ public static String getString(byte[] bytes) { StringBuilder string = new StringBuilder(bytes.length * 2); for (byte b : bytes) { string.append(HEX_CHARS[getHighNibble(b)]).append(HEX_CHARS[getLowNibble(b)]); } return string.toString(); }
/** * Returns a hex string of the given byte. */ public static String getString(byte b) { char[] chars = new char[]{HEX_CHARS[getHighNibble(b)], HEX_CHARS[getLowNibble(b)]}; return new String(chars); }
/** * Writes the given byte as hex value to the given output stream. * @param b the byte to be written * @param output the output stream to be written to * @throws IOException exception if anything went wrong */ public static void writeHexByte(byte b, OutputStream output) throws IOException { output.write(HEX_BYTES[getHighNibble(b)]); output.write(HEX_BYTES[getLowNibble(b)]); }
/** * Returns the bytes corresponding to the ASCII hex encoding of the given byte. */ public static byte[] getBytes(byte b) { return new byte[]{HEX_BYTES[getHighNibble(b)], HEX_BYTES[getLowNibble(b)]}; }
/** * Returns a hex string of the given byte. */ public static String getString(byte b) { char[] chars = new char[]{HEX_CHARS[getHighNibble(b)], HEX_CHARS[getLowNibble(b)]}; return new String(chars); }
/** * Writes the given byte as hex value to the given output stream. * @param b the byte to be written * @param output the output stream to be written to * @throws IOException exception if anything went wrong */ public static void writeHexByte(byte b, OutputStream output) throws IOException { output.write(HEX_BYTES[getHighNibble(b)]); output.write(HEX_BYTES[getLowNibble(b)]); }
/** * Returns a hex string of the given byte array. */ public static String getString(byte[] bytes) { StringBuilder string = new StringBuilder(bytes.length * 2); for (byte b : bytes) { string.append(HEX_CHARS[getHighNibble(b)]).append(HEX_CHARS[getLowNibble(b)]); } return string.toString(); }
/** * Returns the bytes corresponding to the ASCII hex encoding of the given byte. */ public static byte[] getBytes(byte b) { return new byte[]{HEX_BYTES[getHighNibble(b)], HEX_BYTES[getLowNibble(b)]}; }
/** * Returns the bytes corresponding to the ASCII hex encoding of the given bytes. */ public static byte[] getBytes(byte[] bytes) { byte[] asciiBytes = new byte[bytes.length*2]; for(int i=0; i< bytes.length; i++) { asciiBytes[i*2] = HEX_BYTES[getHighNibble(bytes[i])]; asciiBytes[i*2+1] = HEX_BYTES[getLowNibble(bytes[i])]; } return asciiBytes; }
/** * Returns the bytes corresponding to the ASCII hex encoding of the given bytes. */ public static byte[] getBytes(byte[] bytes) { byte[] asciiBytes = new byte[bytes.length*2]; for(int i=0; i< bytes.length; i++) { asciiBytes[i*2] = HEX_BYTES[getHighNibble(bytes[i])]; asciiBytes[i*2+1] = HEX_BYTES[getLowNibble(bytes[i])]; } return asciiBytes; }