Friday, March 21, 2014

Program to wrap up Console input without using inbuilt NIO

1:  package com.mridul.java.helpers;  
2:  import java.io.BufferedReader;  
3:  import java.io.IOException;  
4:  import java.io.InputStreamReader;  
5:  /**  
6:   * Helper class to ease Console read  
7:   * @author Mridul J Kurup  
8:   * @date 2014-03-21  
9:   */  
10:  public class Console {  
11:       /*  
12:        * private default constructor  
13:        */  
14:       private Console(){  
15:            //marking default constructor as private  
16:            //to prevent initialization  
17:       }  
18:       /*  
19:        * method to read from console  
20:        */  
21:       public static String readFromConsole() throws IOException{  
22:            BufferedReader br=new BufferedReader(  
23:                      new InputStreamReader(System.in));  
24:            return br.readLine();  
25:       }  
26:  //End of Console  
27:  }  

No comments:

Post a Comment