Java Utililty Methods Byte Create

List of utility methods to do Byte Create

Description

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

Method

bytetoByte(boolean value)
to Byte
return value ? (byte) 1 : (byte) 0;
bytetoByte(boolean... values)
to Byte
if (values.length > Byte.SIZE) {
    throw new IllegalArgumentException("Expected less or equal to " + Byte.SIZE + " arguments");
byte b = 0;
for (int i = 0; i < values.length; i++) {
    b |= values[i] ? POWERS[i] : 0;
return b;
...
bytetoByte(byte[] data)
to Byte
return (data == null || data.length == 0) ? 0x0 : data[0];
byte[]toByte(byte[] src)
Convert an array of byte 's into an array of byte '.
return src;
bytetoByte(byte[] value)
byte[] -> byte
return (value == null || value.length == 0) ? 0x0 : value[0];
bytetoByte(char c)
Convert char to byte
return (byte) "0123456789ABCDEF".indexOf(c);
inttoByte(char c)
to Byte
byte b = (byte) baseChar.indexOf(c);
return b;
bytetoByte(char c)
to Byte
byte b = (byte) "0123456789ABCDEF".indexOf(c);
return b;
inttoByte(char c)
to Byte
if (c >= '0' && c <= '9')
    return (c - '0');
if (c >= 'A' && c <= 'F')
    return (c - 'A' + 10);
if (c >= 'a' && c <= 'f')
    return (c - 'a' + 10);
throw new RuntimeException("Invalid hex char '" + c + "'");
bytetoByte(char hex)
to Byte
switch (hex) {
case '0':
    return 0;
case '1':
    return 1;
case '2':
    return 2;
case '3':
...