Reading an int from standard input

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

import java.io.*;
 
public class Main 
{
   public static void main(String [] args) {
      BufferedReader stdin = new BufferedReader
         (new InputStreamReader(System.in));
      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!");
      }
   } 
}