Java examples for Language Basics:Console
Read an integer from console
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static BufferedReader buffer = new BufferedReader( new InputStreamReader(System.in)); /**//from w w w . j a v a 2s. c o m * Read an integer from console * * @return The read integer * @throws IOException * If an IO error occurs */ public static int readInt() throws IOException { return Integer.parseInt(buffer.readLine()); } }