Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/10/2013, 10:13
Avatar de rottenp4nx
rottenp4nx
 
Fecha de Ingreso: octubre-2012
Ubicación: Santiago
Mensajes: 417
Antigüedad: 11 años, 6 meses
Puntos: 36
Respuesta: ¿Valadar un ingreso por teclado en java?

Código Java:
Ver original
  1. import java.io.*;
  2.  
  3. public class ValidaNumero{
  4. ---private static BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
  5. ---private boolean x = true;
  6.  
  7. ---public static void main(String args[]) throws IOException{
  8.     while(x){
  9. ------System.out.println("Introduce un numero");
  10. ------try{
  11. ---------int lectura = Integer.parseInt(stdIn.readLine());
  12.            x= false;
  13. ------}catch(NumberFormatException nfe){
  14. ---------System.out.println("Solamente puedes escribir números");
  15. ------}
  16.      }
  17. ---}
  18. }

Algo básico si quieres que se repita
Saludos