I'm relatively new with Java and I've always had problems with the Try/Catch functions in the code so I was wondering if you guys could help me out.
The issue I'm having is that I've written a try/catch but I get an error message saying that the exception is never thrown. I've written a similar statement in another part of my overall code that does work fine so I wonder what the issue is with this one then.
Here is the code:
public String getMatchedLogs(String matchStr, File logFile) {
String fileLine = "";
try {
Scanner ipScan = new Scanner(fileLine);
if (fileLine.indexOf(matchStr) > -1) {
output += fileLine;
}else{
System.out.println(fileLine.indexOf(""));
}
} catch (FileNotFoundException fnfe) {
System.out.println(fnfe.getMessage());
}
return fileLine;
} //end getMatchedLogs
The error is in the catch where it says the exception is never thrown. So if you guys could give me some insight on what's going on I'd greatly appreciate it.