I try to find how many fender words in my txt file but I get nullPointerException. I m waiting for your helps. Thank you :)
public class ScanTxt {
private static BufferedReader buffer;
static int count=0;
public static void main(String...args) throws IOException{
readFile();
}
public static int readFile() throws IOException {
buffer = new BufferedReader(new FileReader("C:/Users/ASUS/Desktop/myfile.txt"));
StringBuilder strbuild = new StringBuilder();
String line = bufferr.readLine();
while (line!=null) {
strbuild.append(line);
strbuild.append("\n");
line = buffer.readLine();
if(line.equalsIgnoreCase("fender")){
count++;
}
}
return count;
}