I am trying to read the log file from the directory: src/main/resources/example.log The file is already there but it throws file not found exception. Here is my code:
public class Main {
public static void main(String[] args) throws FileNotFoundException {
//logfilepath = "src\\main\\resources\\example.log";
Input input=new CommandLineInput();
Textfilehandler textfilehandler = new Textfilehandler();
Log logvariables=new Logvariables();
Firstreadinglog firstreadinglog = new Firstreadinglog(textfilehandler,logvariables);
Logfilehandler logfilehandler = null;
Morereadinglog morereadinglog = new Morereadinglog(textfilehandler,logvariables);
LogAnalyzerApp app=new LogAnalyzerApp(textfilehandler,firstreadinglog,morereadinglog,input);
app.show();
}
}
And the error message is:
java.io.FileNotFoundException: /example.log (No such file or directory) Exception in thread "main" java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) at java.base/java.util.Objects.checkIndex(Objects.java:373) at java.base/java.util.ArrayList.get(ArrayList.java:427) at kln.se.ass2.logfile.Morereadinglog.getcurrentlogstates(Morereadinglog.java:50) at kln.se.ass2.LogAnalyzerApp.show(LogAnalyzerApp.java:35) at kln.se.ass2.Main.main(Main.java:29)
I entered the file path as follows:
src\main\resources\example.log