The it seems that the program can't see the file. The text file is within the same package as the program. Am I missing somethings?
package trycatch;
import java.util.*;
import java.nio.file.Paths;
public class ReadingFromeAFile {
public static void main (String args []) {
try(Scanner scanner = new Scanner (Paths.get("read.txt"))){
while (scanner.hasNextLine()){
String row = scanner.nextLine();
System.out.println(row);
}
}
catch(Exception e){
System.out.println("Error: " + e.getMessage());
}
}
}