Quickest way to accept input

I am using Java. In most questions, one has to accept input like:
1 2 3 4 5
How do I accept “1 2 3 4 5” as array? Using Scanner? readLine()? Tokenizer? (i.e. which one is the fastest)

readLine() with buffered reader and parse the integers

if parse means to use StringTokenizer I’d vote for this answer…

@anuragdbl: from the options in your question I’m using BufferedReader + StringTokenizer (see here for example), but there is also better approach some coders use, for example EgorK here

1 Like

@betlista , I totally agree with you. The custom Inputreader and Outputwriter classes used by @EgorK are the best for Java I/O. +1 from my side.

StringTokenizer is deprecated and usage discouraged. See: http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html So, don’t use it.