I have a folder with .xml files in the project in the resources folder

 src -main -resources -entity entity1.xml entity2.xml 

I don’t know the names of these files beforehand and at first just swirl the entity folder and then take a list of files from it and already work with them.

 File dir = new File(getClass().getClassLoader().getResource("entity").getFile()); File[] arrFiles = dir.listFiles(); 

And so I get a list of files in the entity folder. All this works when I run a project from the IDE or using Gradle, but when I compile and run .jar these resources are no longer loaded.

Found examples where use

getClassLoader().getResourceAsStream("entity")

But the result will be an InputStream and I don’t understand how to convert it to a file (entity folder), which would then take a list of files from it?

0