I'm creating a Quiz program in BlueJ where I read in my questions.csv file and then break them up into an array of objects.
My Question file is located in the same directory as both my package file, and my .class files.
I have already tried specifiying the absolute path file (C://Users ...), and also tried using the .getAbsoluteFilePath() method. None have worked.
If anyone has any solutions as to how I can read in the file successfully, that would be much appreciated. Thank you.
Here is a screenshot of my project directory
Here is the section of my code which reads in the file
String csv = "";
String[] valueList = new String[4];
// identify file
String inputFile = ("questions.csv");
// open file
Scanner fileReader = new Scanner(new File(inputFile));
// loop for every csv row, fetch from file and store
for (int i = 0; i < questionList.length; i++) {
csv = fileReader.nextLine();
valueList = csv.split(",");
// new instance of the Question class (record)
questionList[i] = new Question(valueList[0], valueList[1], valueList[2], valueList[3], valueList[4]);
}
fileReader.close();
} // end readQuestionFile()```
question from:
https://stackoverflow.com/questions/66062389/system-cannot-find-the-specified-file-path-error-bluej 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…