package satish.snt.java;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
public class ReadFromConsole {
public static void main(String a[]){
BufferedReader br = null;
Reader r = new InputStreamReader(System.in);
br = new BufferedReader(r);
String str = null;
try {
do{
System.out.println("Enter Input, exit to quit.");
str = br.readLine();
System.out.println(str);
} while (!str.equalsIgnoreCase("exit"));
} catch (IOException e) {
e.printStackTrace();
} finally{
try{
if(br != null) br.close();
}catch(Exception ex){}
}
}
}
OUTPUT:-
Enter Input, exit to quit.
satish
satish
Enter Input, exit to quit.
0 Comments