I am getting data from a Bluetooth characteristic in bytes and converting it into an array of floats that look like this:
[318.0159, 331.81818, 324.71603, 348.4345, 323.108, 3.2360008]
I want to be able to split this data into 6 strings,
"318.0159" "331.81818" "324.71603" "348.4345" "323.108" "3.2360008".
I have already tried to do this:
EDIT(charData initialized like so):
final StringBuilder stringBuilder = new StringBuilder(bytes.length);
for (byte byteChar : bytes)
stringBuilder.append(String.format("%02X ", byteChar));
String charData = stringBuilder.toString();
String[] data = charData.split(",");
System.out.println(data[1]);
System.out.println(data[2]);
System.out.println(data[3]);
System.out.println(data[4]);
System.out.println(data[5]);
System.out.println(data[6]);
but when it tries to print the first data point, I get the exception:
Unhandled exception in callback
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
Thanks in advance for the help!!
charDatabefore splitting it? Do it and see if it is like the array you posted in your question.split(",")on it. Also, there are no float values in your code.