Created
January 17, 2012 10:27
-
-
Save sbarrat/1626125 to your computer and use it in GitHub Desktop.
Clase que recoge los datos por teclado y devuelve lo que hemos escrito - JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package entrada; | |
import java.io.*; | |
/** | |
* @author Ruben Lacasa | |
* | |
*/ | |
public class Entrada { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
String param = getEntrada("Introduzca un texto: "); | |
System.out.println("Has introducido " + param); | |
} | |
/** | |
* Recoge lo que hemos escrito y lo devuelve | |
* | |
* @param peticion | |
* @return | |
*/ | |
public static String getEntrada(String peticion) { | |
BufferedReader stdin = new BufferedReader( | |
new InputStreamReader(System.in)); | |
System.out.print(peticion); | |
System.out.flush(); | |
try { | |
return stdin.readLine(); | |
} catch (Exception e) { | |
return "Error: " + e.getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment