Friday, September 11, 2015

Java take input from console




 package Study;  
 import java.io.BufferedReader;  
 import java.io.IOException;  
 import java.io.InputStreamReader;  
 public class ConsoleInput {  
      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           ReadFromConsole consolein = new ReadFromConsole();  
           consolein.read();  
      }  
 }  
 class ReadFromConsole {  
      public void read() {  
           System.out.println("enter");  
           try {  
                BufferedReader reader = new BufferedReader(new InputStreamReader(  
                          System.in));  
                String s = reader.readLine();  
                System.out.println(s);  
           } catch (IOException e) {  
                // TODO Auto-generated catch block  
                e.printStackTrace();  
           }  
      }  
 }  

No comments:

Post a Comment