Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.43 KB | None | 0 0
  1.         int cuenta = 0;
  2.         try (Scanner fichero = new Scanner(new BufferedReader(new FileReader("poema.txt")))) {
  3.             while (fichero.hasNext()) {
  4.                 String token = fichero.next();
  5.                 cuenta++;
  6.             }
  7.         } catch (IOException ex) {
  8.             System.err.println("Excepción de lectura");
  9.             ex.printStackTrace();
  10.         }
  11.         System.out.format("Palabras %d%n", cuenta);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement