I referred to this link to get an idea about how to access files in resource
directory.
My java file is at /home/cloudera/Documents/upport/src/main/java/org/mainProject/index/services/SetupService.java
and the resources directory is at /home/cloudera/Documents/Support/src/main/resources
. I wish to create a folder config
in resources and write two text files to it.
Copying to any folder using Files.copy()
gives me Access Denied
. mkdir()
and createDirectory()
were also giving permission errors. So I thought I'll manually copy-paste the files and then access them.
For accessing the files in resources/config
I tried the following but:
This gives me wrong path:
File file = new File("resources/config/file.txt");
String absolutePath = file.getAbsolutePath();
This gives me null
:
SetupService.class.getResource("config/file.txt"));
How should I go about it?