Mostrando las entradas con la etiqueta CLASE LECTURA. Mostrar todas las entradas
Mostrando las entradas con la etiqueta CLASE LECTURA. Mostrar todas las entradas

sábado, 10 de octubre de 2015

CLASE LEER

import java.io.*;

public class Leer 
{

 public String getString()
 {
  InputStreamReader isr = new InputStreamReader(System.in); 
  BufferedReader br = new BufferedReader (isr);
  String s="";
  try
  {
   s = br.readLine();
  }
  catch(Exception ex)
  {
   System.out.println(ex.getMessage());
  }
  return s;
 }

 public int getInt()  
 {
  String s;
  int valInt=0;
  s=this.getString();
  try
  {
   valInt = Integer.parseInt(s);
  }
  catch(Exception ex)
  {
   System.out.println(ex.getMessage());
   
  }
  return valInt;
 }
 public double getDouble()
 {
   String s;
  double aDub=0.0;
  s=this.getString();
   try
   {
    aDub = Double.parseDouble(s);
   }
   catch(Exception ex)
  {
   System.out.println(ex.getMessage());
  }
   return aDub;
    }
 public char getChar()
 {
  String s;
  s="";
    try
    {
     s = this.getString();
    }
    catch(Exception ex)
  {
   System.out.println(ex.getMessage());
  }
   return s.charAt(0);
    }
    public char getCharMay()  
 {
    String s;
    s="";
    try
    {
     s = this.getString();
    }
    catch(Exception ex)
    {
     System.out.println(ex.getMessage());
     
    }
    s = s.toUpperCase();
    return s.charAt(0);
    }
   
    public String getTextMay()  
 {
    String s;
    s="";
    try
    {
     s = this.getString();
    }
    catch(Exception ex)
    {
     System.out.println(ex.getMessage());
     
    }
    s = s.toUpperCase();
    return s;
    }
}