fork(2) download
  1. import java.io.*;
  2.  
  3. class Fichero3 {
  4.  
  5. public static void main(String[] args) {
  6. BufferedReader teclado;
  7. String x;
  8. inStream=new InputStreamReader(System.in);
  9. teclado = new BufferedReader(inStream);
  10.  
  11. File fSalida = new File("prueba.salida");
  12. try {
  13. String s;
  14.  
  15. while ((s = teclado.readLine())!=null ) {
  16. System.out.println(s);
  17.  
  18. if (s == "final"){
  19. s = null;
  20. System.out.println(s);
  21. }
  22.  
  23. System.out.println(s.getClass());
  24. }
  25.  
  26. inStream.close();
  27.  
  28. } catch (FileNotFoundException e) {
  29. System.err.println("Fichero. no encontrado");
  30.  
  31. } catch (IOException e) {
  32. System.err.println("Error de E/S");
  33. }
  34. System.out.println("He terminado");
  35. }
  36. }
Success #stdin #stdout 0.04s 4386816KB
stdin
matarife
Linurillo
stdout
matarife
class java.lang.String
Linurillo
class java.lang.String
He terminado