Java Utililty Methods Char to Byte

List of utility methods to do Char to Byte

Description

The list of methods to do Char to Byte are organized into topic(s).

Method

ByteBufferchar2bb(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;
bytechar2Byte(char c)
char Byte
return (byte) "0123456789ABCDEF".indexOf(c);
bytechar2byte(char ch)
charbyte
switch (ch) {
case '0':
    return 0x00;
case '1':
    return 0x01;
case '2':
    return 0x02;
case '3':
...
bytechar2Byte(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;
...
bytecharToByte(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);
BytecharToByte(char c)
char To Byte
if (c >= Byte.MIN_VALUE && c <= Byte.MAX_VALUE) {
    return (byte) c;
return null;
bytecharToByte(char c)
char To Byte
return (byte) "0123456789ABCDEF".indexOf(c);
bytecharToByte(char c)
Convert char to byte
return (byte) "0123456789ABCDEF".indexOf(c);
bytecharToByte(char c)
char To Byte
for (int i = 0; i < CHARS.length; i++) {
    if (c == CHARS[i]) {
        return (byte) i;
return Byte.MIN_VALUE;
bytecharToByte(char ch)
char To Byte
switch (ch) {
case 48: 
    return 0;
case 49: 
    return 1;
case 50: 
    return 2;
case 51: 
...