Skip to content

Instantly share code, notes, and snippets.

@sbarrat
Created January 17, 2012 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbarrat/1626125 to your computer and use it in GitHub Desktop.
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
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