I'm not entirely sure if this is a Java issue or an IntelliJ issue, but I had a quick question about my File not being found via a path. My Main
class is in the same directory as my input.txt
file.
I though I should be able to do File file = new File("./input.txt")
, except I get FileNotFoundException
. When I do something like File file = new File("src/input.txt")
, it does work.
I get that this may be a solution, but if I try to run this code outside of IntelliJ without a src
directory, this will lead to an error where the File can't be found.
Is there any reason why I can't just do ./input.txt
to specify that the File is in the same directory as the Main file?