The static method belows reads a line from the console using Scanner class.

Java Code:
	public static String readLine() throws InputMismatchException
	{
		Scanner in = new Scanner(System.in);  
		String str;
		System.out.println("Enter an integer value: ");
		str = in.nextLine();
		return str;
	}