-6

I have following project structure:

src
--Main.java
--resources
----Users.txt

And I am trying to create a file from Main.java like that:

      File file = new File("resources/Users.txt");

However, I never succeed at doing so.

Why?

alegrowski
  • 231
  • 3
  • 8

1 Answers1

0

If it is a regular file outside a .jar, you are using a relative path. That means, the path to the file is formed from the path where you are calling the file from + the relative path. To make it work, you should invoke java within src folder

Nadir
  • 1,739
  • 11
  • 20