I am using the google's common IO, library to read the files in my resources folder of Spring boot app. its working perfectly fine in the IntelliJ, but when I am running this from the command line, My app is picking the application.yml
present in the same resources
folder but not picking other files in the same folder.
I've checked that files are present in the jar file, as shown below
unzip -l my.jar | grep ".json"
983 04-14-2022 16:16 BOOT-INF/classes/abc.json
423 04-14-2022 16:16 BOOT-INF/classes/xyz.json
But App is throwing following File not found exception, with the same location.
java.io.FileNotFoundException: file:/Users/amit/code/so-search/target/my.jar!/BOOT-INF/classes!/abc.json (No such file or directory)
This is how I am reading the files in my code.
public static FileReader getFileReader(String fileName) throws FileNotFoundException {
File file = new File(Resources.getResource(fileName).getFile());
return new FileReader(file);
}