I am simply trying to make a very basic java program to read a file. However I get the error that it can't find my file:
Exception in thread "main" java.io.FileNotFoundException: read.txt (The system cannot find the file specified)
I checked and I have not misspelled my file name, and the file is already in the same file directory as the program.
Here is the code:
import java.io.*;
import java.util.*;
public class save_files {
public static void main(String[] args) throws FileNotFoundException {
File file = new File("read.txt");
Scanner scanner = new Scanner(file);
String line = scanner.nextLine();
System.out.println(line);
}
}