The conditions do not indicate wether or not you should or shouldn't count occourances of the word "world" within another string or not.
When the split function encounters an instance of the word then the array will be contain two elements. if you don't encounter the word "world" then the size will be one.
Therefore when subtracting one of the array size we get the amount of times the word appears in the text.
This might not be the intended way to solve this but this should work if you include all substing occourances.
package de.codegym.task.task19.task1907;
/*
Wörter zählen
*/
import java.io.*;
import java.nio.Buffer;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String filename = input.readLine();
input.close();
BufferedReader reader = new BufferedReader(new FileReader(filename));
int counter = 0;
String line;
while ((line = reader.readLine()) != null) {
// line = line.toLowerCase();
String[] arr = line.split("world");
int occourance = arr.length -1;
counter = counter + occourance;
}
reader.close();
System.out.println(counter);
}
}