Home java Relative path to files in IntelliJ IDEA

Relative path to files in IntelliJ IDEA

Author

Date

Category

if you specify the path to the file

E: \\ IdeaProjects \\ MyProject \\ 01 \\ src \\ main \\ java \\ org \ \ Council \\ test.txt

The idea sees the file, and
in this version:

src / main / java / org / Council / test.txt

doesn’t work

Moreover, on another PC, the option indicating the relative path (the latter) works (one project).

tried to do Copy Relative Path – pasted the copied path, useless

where can I set IDEAS in the settings?

File – Project Structure – Modules
tried, to no avail

tried to put the file side by side, in the same directory, also does not work.
the search tips didn’t help


Answer 1, authority 100%

when you open it as a project, the paths start from the folder of this project. therefore paths must be specified with ./src/main/

In your case it will be ./src/main/java/org/Council/test.txt

As a reminder, ./src/main/java/org/Council/ is not meant to store resources. use the resources

folder for this

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions