Try this
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class ReadFile {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
String classroom = scanner.nextLine().toLowerCase();
BufferedReader input = new BufferedReader(new FileReader("data.txt"));
String data = input.readLine();
int subjectIndex = 10;
String[] items = new String[0];
boolean match=false;
while (data != null) {
items = data.split(",");
if (items.length > 10) {
if (items[subjectIndex].toLowerCase().contains(classroom)) {
System.out.println("There students in enrolling in " +classroom+ " are " +items[0]+ " " + items[1] + " (" + items[2] +")");
match = true;
}
}
data = input.readLine();
}
if(!match)
{
System.out.println("The subject " +classroom+ " is not taught at our school");
}
}
}
Input
AWQ2O0ECHC2D0ECHV2O0BENG2D0DFSF2D0AGLC2O0BMPM2D0APPL2OMBSNC2D0C
Output
There students in enrolling in awq2o0echc2d0echv2o0beng2d0dfsf2d0aglc2o0bmpm2d0appl2ombsnc2d0c are Amath Brandon (522442)
There are 1 students in awq2o0echc2d0echv2o0beng2d0dfsf2d0aglc2o0bmpm2d0appl2ombsnc2d0c
0
solved File handling comparing string with text file