Reading an int from standard input

Wrap in a BufferedReader object and call the method readLine. Then convert that string to an int.

public class Main 
   public static void main(String [] args) {
      BufferedReader stdin = new BufferedReader
         (new InputStreamReader(;
      String number;
      System.out.println ("Enter a integer number:");
      try {
         number = stdin.readLine();
         int n = Integer.parseInt(number);
         System.out.println("You entered " + n);
      catch(Exception e) {
         System.out.println("You did not enter a valid number!");