@Test public void testNibbleToChar() { Assert.assertEquals(nibbleToChar(0x00), '0'); Assert.assertEquals(nibbleToChar(0x01), '1'); Assert.assertEquals(nibbleToChar(0x02), '2'); Assert.assertEquals(nibbleToChar(0x03), '3'); Assert.assertEquals(nibbleToChar(0x04), '4'); Assert.assertEquals(nibbleToChar(0x05), '5'); Assert.assertEquals(nibbleToChar(0x06), '6'); Assert.assertEquals(nibbleToChar(0x07), '7'); Assert.assertEquals(nibbleToChar(0x08), '8'); Assert.assertEquals(nibbleToChar(0x09), '9'); Assert.assertEquals(nibbleToChar(0x0A), 'A'); Assert.assertEquals(nibbleToChar(0x0B), 'B'); Assert.assertEquals(nibbleToChar(0x0C), 'C'); Assert.assertEquals(nibbleToChar(0x0D), 'D'); Assert.assertEquals(nibbleToChar(0x0E), 'E'); Assert.assertEquals(nibbleToChar(0x0F), 'F'); Assert.assertEquals(nibbleToChar(0x10), '0'); Assert.assertEquals(nibbleToChar(0x21), '1'); Assert.assertEquals(nibbleToChar(0x32), '2'); Assert.assertEquals(nibbleToChar(0x43), '3'); Assert.assertEquals(nibbleToChar(0x54), '4'); Assert.assertEquals(nibbleToChar(0x65), '5'); Assert.assertEquals(nibbleToChar(0x76), '6'); Assert.assertEquals(nibbleToChar(0x87), '7'); Assert.assertEquals(nibbleToChar(0x98), '8'); Assert.assertEquals(nibbleToChar(0xA9), '9'); Assert.assertEquals(nibbleToChar(0xBA), 'A'); Assert.assertEquals(nibbleToChar(0xCB), 'B'); Assert.assertEquals(nibbleToChar(0xDC), 'C'); Assert.assertEquals(nibbleToChar(0xED), 'D'); Assert.assertEquals(nibbleToChar(0xFE), 'E'); Assert.assertEquals(nibbleToChar(0xFF), 'F'); }
public static char nibbleToChar(int n) { n = n & 0xF; return (n <= 9) ? (char) ('0' + n) : (char) ('A' - 0xA + n); }
Handy { public static char nibbleToChar(int n) { n = n & 0xF; return (n <= 9) ? (char) ('0' + n) : (char) ('A' - 0xA + n); } }
Handy { public static char nibbleToChar(int n) { n = n & 0xF; return (n <= 9) ? (char) ('0' + n) : (char) ('A' - 0xA + n); }  }
Handy { public static char nibbleToChar(int n) { n = n & 0xF; return (n <= 9) ? (char) ('0' + n) : (char) ('A' - 0xA + n); }  static char nibbleToChar(int n); static StringBuilder appendByteAsHex(StringBuilder sb, int n); static String byteToHexString(int n); static StringBuilder appendByteArrayAsHex(StringBuilder sb, byte[] ab, int of, int cb); static StringBuilder appendByteArrayAsHex(StringBuilder sb, byte[] ab); static String byteArrayToHexString(byte[] ab, int of, int cb); static String byteArrayToHexString(byte[] ab); static byte[] hexStringToByteArray(String s); static String byteArrayToHexDump(byte[] ab, int of, int cb, int cBytesPerLine); static String byteArrayToHexDump(byte[] ab, int cBytesPerLine); static int countHexDigits(int n); static StringBuilder appendIntAsHex(StringBuilder sb, int n, int cch); static StringBuilder appendIntAsHex(StringBuilder sb, int n); static String intToHexString(int n); static int countHexDigits(long n); static StringBuilder appendLongAsHex(StringBuilder sb, long n, int cch); static StringBuilder appendLongAsHex(StringBuilder sb, long n); static String longToHexString(long n); static int renderByteToHex(int n, char[] ach, int of); static int renderIntToHex(int n, char[] ach, int of, int cch); static int renderLongToHex(long n, char[] ach, int of, int cch); static boolean isDigit(char ch); static int digitValue(char ch); static boolean isHexit(char ch); static int hexitValue(char ch); static boolean isAsciiLetter(char ch); static int countChar(String s, char ch); static String[] parseDelimitedString(String s, char chDelim); static String indentLines(String sText, String sIndent); static boolean isCharEscaped(char ch); static StringBuilder appendChar(StringBuilder sb, char ch); static String quotedChar(char ch); static StringBuilder appendString(StringBuilder sb, String s); static String quotedString(String s); static long readPackedLong(DataInput in); static void writePackedLong(DataOutput out, long n); static int readPackedInt(DataInput in); static int readMagnitude(DataInput in); static int readIndex(DataInput in); static int readUtf8Char(DataInput in); static void writeUtf8Char(DataOutput out, int ch); static String readUtf8String(DataInput in); static void writeUtf8String(DataOutput out, String s); static InputStream toInputStream(File file); static byte[] readFileBytes(File file); static char[] readFileChars(File file); static char[] readFileChars(File file, String sEncoding); static T[] dedupAdds(T[] aoBase, T[] aoAdd); static T[] append(T[] aoBase, T[] aoAdd); static T[] appendHead(T[] aoBase, T oAdd); static ArrayList<T> startList(T[] ao, int c); static ArrayList<T> appendList(ArrayList<T> list, T[] ao, int of, int c); static boolean anyMatches(T[] ao, T o); static int hashCode(final Object o); static boolean equals(final Object o1, final Object o2); static int compareObjects(final Comparable o1, final Comparable o2); static boolean equalArraysNullOk(final Object[] ao1, final Object[] ao2); static int compareArrays(final Comparable[] ao1, final Comparable[] ao2); static boolean checkElementsNonNull(Object[] ao); }
Handy { public static char nibbleToChar(int n) { n = n & 0xF; return (n <= 9) ? (char) ('0' + n) : (char) ('A' - 0xA + n); }  static char nibbleToChar(int n); static StringBuilder appendByteAsHex(StringBuilder sb, int n); static String byteToHexString(int n); static StringBuilder appendByteArrayAsHex(StringBuilder sb, byte[] ab, int of, int cb); static StringBuilder appendByteArrayAsHex(StringBuilder sb, byte[] ab); static String byteArrayToHexString(byte[] ab, int of, int cb); static String byteArrayToHexString(byte[] ab); static byte[] hexStringToByteArray(String s); static String byteArrayToHexDump(byte[] ab, int of, int cb, int cBytesPerLine); static String byteArrayToHexDump(byte[] ab, int cBytesPerLine); static int countHexDigits(int n); static StringBuilder appendIntAsHex(StringBuilder sb, int n, int cch); static StringBuilder appendIntAsHex(StringBuilder sb, int n); static String intToHexString(int n); static int countHexDigits(long n); static StringBuilder appendLongAsHex(StringBuilder sb, long n, int cch); static StringBuilder appendLongAsHex(StringBuilder sb, long n); static String longToHexString(long n); static int renderByteToHex(int n, char[] ach, int of); static int renderIntToHex(int n, char[] ach, int of, int cch); static int renderLongToHex(long n, char[] ach, int of, int cch); static boolean isDigit(char ch); static int digitValue(char ch); static boolean isHexit(char ch); static int hexitValue(char ch); static boolean isAsciiLetter(char ch); static int countChar(String s, char ch); static String[] parseDelimitedString(String s, char chDelim); static String indentLines(String sText, String sIndent); static boolean isCharEscaped(char ch); static StringBuilder appendChar(StringBuilder sb, char ch); static String quotedChar(char ch); static StringBuilder appendString(StringBuilder sb, String s); static String quotedString(String s); static long readPackedLong(DataInput in); static void writePackedLong(DataOutput out, long n); static int readPackedInt(DataInput in); static int readMagnitude(DataInput in); static int readIndex(DataInput in); static int readUtf8Char(DataInput in); static void writeUtf8Char(DataOutput out, int ch); static String readUtf8String(DataInput in); static void writeUtf8String(DataOutput out, String s); static InputStream toInputStream(File file); static byte[] readFileBytes(File file); static char[] readFileChars(File file); static char[] readFileChars(File file, String sEncoding); static T[] dedupAdds(T[] aoBase, T[] aoAdd); static T[] append(T[] aoBase, T[] aoAdd); static T[] appendHead(T[] aoBase, T oAdd); static ArrayList<T> startList(T[] ao, int c); static ArrayList<T> appendList(ArrayList<T> list, T[] ao, int of, int c); static boolean anyMatches(T[] ao, T o); static int hashCode(final Object o); static boolean equals(final Object o1, final Object o2); static int compareObjects(final Comparable o1, final Comparable o2); static boolean equalArraysNullOk(final Object[] ao1, final Object[] ao2); static int compareArrays(final Comparable[] ao1, final Comparable[] ao2); static boolean checkElementsNonNull(Object[] ao); static byte[] EMPTY_BYTE_ARRAY; static char[] EMPTY_CHAR_ARRAY; static String[] NO_ARGS; }