I have String[] array that contains a string with three data points separated by the character ":" like the following string:
SNSD_OOT:511:127
I need to extract this values from the String[] array. I tried using statusOxymetry[i] = Arrays.toString(valuesOxymetry[i].split(":")); However I end up with the following data. I need to store each element into an array.
[SNSD_OOT, 511, 127]
My goal is to end with 3 arrays, one where anything before the first ":" appears, another one for the data after the first ":", and the final one for the data after the second ":"
1stArray[0] = SNSD
2ndArray[0] = 511
3rdArray[0] = 127
I need to separate the first, second, and third element into a separate array each. I am feeling a bit confused on how to do this properly.
String[] valuesOxymetry = message.getData().getString("raw"));
int total = valuesOxymetry.length - 2;
String[] statusOxymetry = new String[total];
String[] hrmOxymetry = new String[total];
String[] spo2Oxymetry = new String[total];
//ignore first two data points (timestamp)
for(int i = 2; i < total; i++) {
System.out.println("Pulse values: " + valuesOxymetry[i]);
statusOxymetry[i] = Arrays.toString(valuesOxymetry[i].split(":"));
System.out.println("Only status " + statusOxymetry[i]);
}
3separate arrays if there are only3elements?