Reputation: 75
How to get the absolute path of the files(cacerts.pem,client.pem,client-key.pem) that are kept under the folders as below in the image
This is in the eclipse and gradle environment
Upvotes: 0
Views: 879
Reputation: 91
Using Spring:
Resource resource = new ClassPathResource("file/location/cert.pem");
File file = resource.getFile();
Upvotes: 0
Reputation: 81
I usually use a cheat to get there!
Paths.get(SomeClass.class.getClassLoader().getResource("").toURI());
When the java code is built all resources go to their target output, for example you would have something like target/io/geocloud/management/client/* .
For you specific problem i would change a bit the code and do something like
Paths.get(SomeClass.class.getClassLoader().getResource("io/geocloud/management/client/ca/cacerts.pem").toURI()).toAbsolutePath().toString();
Upvotes: 2