Знаю что валидатор прав, но я даже не знаю какие ещё могут быть случаи в которых слово world не считается..
package com.javarush.task.task19.task1907;
/*
Считаем слово
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
FileReader reader = new FileReader(bufferedReader.readLine());
ArrayList<Integer> list = new ArrayList<>();
while (reader.ready()) {
int data = reader.read();
list.add(data);
}
reader.close();
bufferedReader.close();
int col = 0;
for (int i = 0; i < list.size(); i++) {
if (list.get(i) == 119 && list.get(i + 1) == 111 && list.get(i + 2) == 114 && list.get(i + 3) == 108 && list.get(i + 4) == 100){
try {
if (list.get(i - 1) == 44 && (list.get(i + 5) == 44 || list.get(i + 5) == 0)) col++;
} catch (ArrayIndexOutOfBoundsException e) {
col++;
} catch (IndexOutOfBoundsException e) {
col++;
}
}
}
System.out.println(col);
}
}