I read line with
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader.readLine();
Example input is
try
line = reader.readLine(); String[] s = line.split(" "); ...
you can look to StringTokenizer also, but one of the fastest will be to read bytes and iterate them and convert the ascii (utf8?) coded numbers yourself ;)