java taking console input

Java
String str = System.console().readLine();
Source

Also in Java: