Guys could you please help me on this part, last condition is not getting satisfied.
package com.codegym.task.task19.task1907;
import java.io.*;
import java.util.*;
/*
Counting words
Requirements:
1. The program must read the file name from the console (use BufferedReader).
2. The BufferedReader used for reading input from the console must be closed after use.
3. The program must read the file's contents (use the FileReader constructor that takes
a String argument).
4. The file input stream (FileReader) must be closed.
5. The program must output to the console the number of times the word "world" appears in the file.
*/
public class Solution {
private static int counter = 0;
public static void main(String[] args) {
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileReader fileReader = new FileReader(reader.readLine());
int data;
while(fileReader.ready()){
data = fileReader.read();
if(new Integer(data).toString().equals("world")){
counter++;
}
}
reader.close();
fileReader.close();
}catch(Exception ex){
}
System.out.println(counter);
}
}