тест такой - ", , df, asdfg, fg, adf, world, world, werworld"
вывод - 2 раза найдено слово "world"
собсна вопрос по слову "werworld", нужно ли его считать?
package com.javarush.task.task19.task1907;
/*
Четные символы
*/
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String a = reader.readLine();
FileReader fileReader = new FileReader(a);
String q = readUsingFiles(a);
String [] w = q.split(", ");
int count = 0;
for (int i = 0; i < w.length; i++) {
if (w[i].equals("world"))
count++;
}
System.out.println(count);
fileReader.close();
reader.close();
}
private static String readUsingFiles(String fileName) throws IOException {
return new String(Files.readAllBytes(Paths.get(fileName)));
}
}