Java tutorial
import java.io.Console; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Console cnsl = System.console(); if (cnsl != null) { System.out.print("Enter name : "); Scanner scan = new Scanner(cnsl.reader()); while (scan.hasNext()) { String str = scan.next(); System.out.println(str); } } } }