Skip to content

Instantly share code, notes, and snippets.

@sbarrat sbarrat/Entrada.java
Created Jan 17, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.