List of utility methods to do Char to Byte
ByteBuffer | char2bb(char[] c) charbb int len = c.length; ByteBuffer bb = ByteBuffer.allocateDirect(len); for (int i = 0; i < len; i++) bb.put((byte) c[i]); bb.rewind(); return bb; |
byte | char2Byte(char c) char Byte return (byte) "0123456789ABCDEF".indexOf(c); |
byte | char2byte(char ch) charbyte switch (ch) { case '0': return 0x00; case '1': return 0x01; case '2': return 0x02; case '3': ... |
byte | char2Byte(char ch) char Byte if (ch >= '0' && ch <= '9') { return (byte) (ch - '0'); } else if (ch >= 'a' && ch <= 'f') { return (byte) (ch - 'a' + 10); } else if (ch >= 'A' && ch <= 'F') { return (byte) (ch - 'A' + 10); } else { return 0; ... |
byte | charToByte(char aChar) char To Byte byte ref; if (aChar >= '0' && aChar <= '9') { ref = (byte) '0'; } else if (aChar >= 'a' && aChar <= 'f') { ref = (byte) 'a' - 10; } else { throw new IllegalArgumentException("The char '" + aChar + "' is a not valid hex value"); return (byte) (aChar - ref); |
Byte | charToByte(char c) char To Byte if (c >= Byte.MIN_VALUE && c <= Byte.MAX_VALUE) { return (byte) c; return null; |
byte | charToByte(char c) char To Byte return (byte) "0123456789ABCDEF".indexOf(c); |
byte | charToByte(char c) Convert char to byte return (byte) "0123456789ABCDEF".indexOf(c); |
byte | charToByte(char c) char To Byte for (int i = 0; i < CHARS.length; i++) { if (c == CHARS[i]) { return (byte) i; return Byte.MIN_VALUE; |
byte | charToByte(char ch) char To Byte switch (ch) { case 48: return 0; case 49: return 1; case 50: return 2; case 51: ... |