Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Arrays;
- public class HW01_4 {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String path = reader.readLine();
- String word = reader.readLine();
- File file = new File(path);
- BufferedReader input = new BufferedReader(new FileReader(file));
- long occurrences = input.lines()
- .flatMap(f -> Arrays.stream(f.trim().split(" ")))
- .map(m -> m.toUpperCase())
- .filter(f -> f.length() > 0&&f.equals(word.toUpperCase()))
- .count();
- System.out.print(occurrences);
- }
- }
Add Comment
Please, Sign In to add comment