Commit a16b6bbe by Patryk Czarnik

liczenie słów - początek

parent 2f9a320f
package domowe.r4.pan_tadeusz;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class WypiszSlowa {
public static void main(String[] args) {
try(Scanner scanner = new Scanner(new File("pliki/pan_tadeusz.txt"))) {
int ile = 0;
while(scanner.hasNext()) {
String slowo = scanner.next();
System.out.println("[" + slowo + "]");
ile++;
}
System.out.println("Liczba słów: " + ile);
} catch(FileNotFoundException e) {
e.printStackTrace();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment