My project is created by Intellij, and this is a gradle project, path is: c:\project\
This is the program
Path path = Paths.get("input.txt");
List<String> lines=java.nio.file.Files.readAllLines(path, Charset.forName("utf-16le"));
I must use relative path, because I will use this command to run the program in future, and the input.txt
java -jar project.jar
The jar are generated at
C:\project\out\artifacts\project_jar\project.jar
So I copy input.txt to
C:\project\out\artifacts\project_jar\input.txt
But my program cannot found the input.txt if I run the program in intellij at development time
it only can read the file if I place the file at
C:\project\input.txt
I don't want to manually copy all dependent files to jar's path every time I release the program
How to make sure the file can be read in both situations?