I am tring to convert a set of strings to a byte[] array. At first, I do something like this to convert a byte array to a string:
public String convertByte(byte[
Using Byte.parseByte
may help making your second snippet work.
But, unless you have some specific reason to use that kind of representation, I'd encode strings to byte arrays using the Java methods mentioned in other answers.
public static byte[] convertStr(String ln)
{
System.out.println(ln);
String[] st = ln.split(" * ");
byte[] byteArray = new byte[23];
for(int i = 0; i < st.length; i++)
{
byteArray[i] = Byte.parseByte(st[i]);
}
return byteArray;
}