READUTILITY SOURCE


/* The following methods provide utilities for reading integers, floats, doubles, strings, character
 and method for flushing the input buffer. Note that once the required data is read from the input buffer, the rest of the buffer is discarded. So only one data item can be input per line.
*/
 

import java.io.*;

class ReadUtility{
 
     static  BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
 

/*------------------------------------------------*/

     public static int readInt() {

      try{
        return(Integer.valueOf(console.readLine()).intValue());
      }
      catch(IOException e){
        return(0);
      }
     }
 

/*------------------------------------------------*/
 
 

     public static float readFloat() {
      try{
          return( Float.valueOf(console.readLine()).floatValue());
      }
      catch(IOException e){
          return(0f);
      }
     }
 
/*------------------------------------------------*/
 
 

     public static double readDouble() {
       try{
          return( Double.valueOf(console.readLine()).doubleValue());
       }
       catch(IOException e){
          return(0.0);
       }
     }
 

/*------------------------------------------------*/
 

 
     public static String readString() {
       try{
        return( console.readLine());
       }
       catch(IOException e){
          return("");
       }
     }
 

/*------------------------------------------------*/
 
 

     public static char readChar() {
       try{
           return( console.readLine().charAt(0));
       }
       catch(IOException e){
         return('0');
       }
     }
 
 
 

/*------------------------------------------------*/
 
 

     public static void flushBuffer() {
        char c= '\n';
        do{
          try{
            c = (char) System.in.read();
          }
          catch(IOException e){
            return;
          }
        }while (c != '\n');
 
     }

}