I'm able to read a file by specifying the file path (which is in my src project) but I'm trying to read or open it by providing its name when the user is prompted by the command line in the first argument.
File fileName = new File("/Users/blad/Documents/CS2/Labs/Project01/input.txt");
try {
Scanner sc = new Scanner(fileName);
while(sc.hasNextLine()){
System.out.println(sc.nextLine());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
The name of the file is "input.txt" Is there a way to approach that? Thank you.