This example code reads a line from the standard input(console) using the BufferedReader and InputStreamReader.

Java Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class InputExp {
	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			System.out.println("Enter the line :- ");
			String s = br.readLine();
			System.out.println("You have Enterd :- " + s);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}