I'm attempting to make my first program that involves file input, but I'm running into problems finding the .txt file.
I placed the file inside the same folder as the rest of the project, but it still doesn't seem to be finding it. Am I doing something wrong?
That's the portion of the code that is supposed to read the file. I cut out the declaration of the Scanner in and the rest of the class, but I figured that wouldn't have anything to do with the problem I'm having.
I placed the file inside the same folder as the rest of the project, but it still doesn't seem to be finding it. Am I doing something wrong?
Code:
try
{
in = new Scanner(new File("File Reading.txt"));
String test = in.nextLine();
System.out.println(test);
}
catch(Exception i)
{
System.out.println("Error: " + i.getMessage());
}
That's the portion of the code that is supposed to read the file. I cut out the declaration of the Scanner in and the rest of the class, but I figured that wouldn't have anything to do with the problem I'm having.
Comment