I think it'd be easier for you to add the numbers to string

String thing += num + " "
and then parse it

int ln = 0;
for(int i=0;i<thing.length()) {
if(this.substring(i,i) == " ") {
...