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(String string)
to Byte
return (byte) toInt(string);
byte[]toByte(String string)
to Byte
byte[] data = new byte[string.length() / 2];
int loc = 0;
for (int i = 0; i < string.length(); i += 2) {
    int hex = Integer.decode("0x" + string.charAt(i) + "" + string.charAt(i + 1));
    data[loc++] = (byte) hex;
return data;
bytetoByte(String string)
to Byte
assert string.length() == 2;
byte b = (byte) ((byte) (decodeHexChar(string.charAt(0)) << 4) | (byte) (decodeHexChar(string.charAt(1))));
return b;
BytetoByte(String value)
to Byte
if (null == value) {
    return null;
value = value.trim();
if ("null".equals(value)) {
    return null;
return Byte.parseByte(value);
...
BytetoByte(String value)
to Byte
if (value != null) {
    try {
        return Byte.parseByte(value);
    } catch (NumberFormatException e) {
return null;
bytetoByte(T value)
to Byte
return (value != null ? value.byteValue() : null);
inttoByteBE(int value, byte[] dst, int offset)
int to 32bit
dst[offset] = (byte) ((value >> 24) & 0xFF);
dst[++offset] = (byte) ((value >> 16) & 0xFF);
dst[++offset] = (byte) ((value >> 8) & 0xFF);
dst[++offset] = (byte) (value & 0xFF);
return 4;
byte[]toByteByAddress(String address)
to Byte By Address
if (address == null) {
    throw new IllegalArgumentException("address is invalid");
String[] ips = address.split("[.:_]");
if (ips.length < 4) {
    throw new IllegalArgumentException("broker is invalid");
int pos = 0;
...
byte[]toByteByHex(String address)
to Byte By Hex
if (address == null) {
    throw new IllegalArgumentException("address is invalid");
int len = address.length();
if (len < 8) {
    throw new IllegalArgumentException("address is invalid");
byte[] buf;
...
bytetoByteColor(int i)
integer color to byte color.
return (byte) ((i >>> 0) & 0xFF);