Advertisement
00vk

task1907/Solution

Dec 6th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public class Solution {
  2.  
  3.     public static void main(String[] args) throws IOException {
  4.         BufferedReader filenameReader = new BufferedReader(new InputStreamReader(System.in));
  5.         try (BufferedReader fileReader = new BufferedReader(new FileReader(filenameReader.readLine()))) {
  6.             String content = fileReader.lines().collect(Collectors.joining(" "));
  7.             int count = (int) Arrays.stream(content.split("\\W+"))
  8.                                     .filter("world"::equals).count();
  9.             System.out.println(count);
  10.         }
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement