Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting input from user in Console without using Scanner

I would like to know about other ways of getting input from users using other classes like BufferedReader,etc rather than using Scanner class. So, was there any other way of getting input from the user? If so, was it efficient than Scanner class?

like image 909
Gowtham Avatar asked Dec 16 '22 11:12

Gowtham


1 Answers

if you are using the Java SE6 or higher then you can make use of Console clas

   Console console = System.console();
   if (console==null){
      System.out.print("console not available ");
   }else {
      String line = console.readLine("Enter name :");
      System.out.print("your name :"+line);
   }
like image 105
ajduke Avatar answered Jan 14 '23 19:01

ajduke