Any hint? Tk you!
package com.codegym.task.task19.task1907;
/*
Counting words
*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
br.close();
BufferedReader bufferedReader = new BufferedReader(new FileReader(s));
List<String>list = new ArrayList<>();
while(bufferedReader.ready()){
String x = bufferedReader.readLine();
String[] str = x.split("\\.");
list.addAll(Arrays.asList(str));
}
int count = 0;
for(String abc : list){
if(abc.equals("world")){
count = count + 1;
}
}
System.out.println(count);
bufferedReader.close();
}
}