I have a string that looks like this: ["1011000", "1000010", "1001101", "1000011"].
My argument is coming from elsewhere so it needs to be this way.
I need to typecast this to a real byte array.
Here's my method:
public void send(String[] payloadarr) throws IOException {
byte [] payload = {};
for (int i = 0; i < payloadarr.length; i++) {
byte x = (byte) payloadarr[i];
payload[i] = x;
}
//do byte stuff with payload
}
It doesn't work, however. Complains about inconvertable types String to byte.
Can anyone help me with this typecasting?
String.getBytes()orString.getBytes(ENCODING)? I made this a comment because I'm not aware of your requirements.payloadarris an ARRAY of strings.