Read int from stdin all in just 1 Line (Java 6 or higher)

int n = Integer.parseInt(System.console().readLine());
Note that that under most IDEs System.console will return NULL when the application is invoked via a launcher making it hard to debug.