java - BufferedReader space separated input -


first i'd mention not realy experienced in java, , searched stackoverflow solution problem , either didn't find or didn't understand answer, asking now:

i wanted start working bufferedreader , didn't find guide understood propely, picked bits here , there , wrote example :

bufferedreader input = new bufferedreader (new inputstreamreader (system.in)); int x = integer.parseint(input.readline()); string y = input.readline(); system.out.println(x); 

this code worked input 34 enter abc, @ im trying achieve need input 34 abc separated space inputed , x 34 , y abc. work when using scanner, problem scanner times out exercise i'm doing because it's slow.

is there simple way input space separated scanner?

try this,

stringtokenizer tk = new stringtokenizer(input.readline()); int m = integer.parseint(tk.nexttoken()); string s = tk.nexttoken(); 

this faster string.split();


Comments