I'm writing a text analyzer program that counts words and sentences etc. The user is asked to enter a file to analyze.
Ex.
"Enter a file to analyze : " "Enter : stuff.txt"
I have the file saved in my project, but only works when I put the full file path, below is how it's handled.
public void loadFromFile(String filePath) {
try {
theText = new String(Files.readAllBytes(Paths.get(filePath)));
} catch (Exception e) {
System.out.println("could not load file " + filePath);
e.printStackTrace();
}
}
I want to simply write stuff.txt instead of the full file path