java - StringTokenizer getting whole line -
i'm using stringtokenizer read game map. problem don't know how whole line of file. example here's .txt file
block 128 0 52 3 block 192 0 speeditem 200 64 block 256 0 platform 150 70 500 0 false block 320 0 12 75 block 384 0
and here how try print whole line
filehandle file = gdx.files.internal("data/" + level + ".txt"); stringtokenizer tokens = new stringtokenizer(file.readstring()); while(tokens.hasmoretokens()){ string type = tokens.nexttoken(); system.out.println(type); // first word of line if(type.equals("block")){ list.add(new brick(integer.parseint(tokens.nexttoken()), integer.parseint(tokens.nexttoken()))); }
so here's results
block block speeditem block platform block block
but need print numbers in lines example
block 128 0 52 3 block 192 0 speeditem 200 64 .... ....
why using stringtokenizer class? it's legacy class. use split() method. make job simpler you.
Comments
Post a Comment