I am trying to read a file line by line and take action on every line that begins with the character 'Q'. I keep getting this error after trying many solutions from SO and the JavaDoc. I cannot figure out for the life of me what I am getting it. My method looks like this:
public Question makeQuestion(){
//scanner checks line and takes action
while(fileScan.hasNextLine()){
//save the line
String line = fileScan.nextLine();
//if line is blank move on to next line
if(line.isEmpty()) fileScan.nextLine();
//if line starts with Q do something
if(line.charAt(0) == 'Q'){
System.out.println(line);
}
}
The method finds the first line that begins with Q but fails after that. What could I be doing wrong?