I assume that panoBuffer
contains more than one comma, which perhaps leads to that you find a comma that comes before idIndex
.
Try replacing
panoBuffer.indexOf(',')
with panoBuffer.indexOf(',', idIndex+1)
instead, this way you will find the first comma that comes after idIndex
.
You should also make sure to check that you actually do find a value by verifying that the result of indexOf
is greater than -1
as specified in the documentation for String#indexOf(int,int).