Android Utililty Methods String to Byte Array Convert

List of utility methods to do String to Byte Array Convert

Description

The list of methods to do String to Byte Array Convert are organized into topic(s).

Method

byte[]toBytes(String hexString)
Get the byte representation of an ASCII-HEX string.
hexString = hexString.replace(" ", "");
if (hexString == null || hexString.length() % 2 != 0) {
    throw new RuntimeException(
            "Input string must contain an even number of characters");
char[] hex = hexString.toCharArray();
int length = hex.length / 2;
byte[] raw = new byte[length];
...
byte[]toBytes(String hexString)
Get the byte representation of an ASCII-HEX string.
if (hexString == null || hexString.length() % 2 != 0) {
    throw new RuntimeException(
            "Input string must contain an even number of characters");
char[] hex = hexString.toCharArray();
int length = hex.length / 2;
byte[] raw = new byte[length];
for (int i = 0; i < length; i++) {
...
byte[]toBytes(String s)
to Bytes
return toBytes(s.toCharArray());
ByteStringstringToByteString(String string)
string To Byte String
return ByteString.copyFromUtf8(string);