I am trying to get a path to a Resource but I have had no luck.
This works (both in IDE and with the JAR) but this way I can\'t get a path to a file, only the file
In my case, I have used a URL object instead Path.
File
File file = new File("my_path");
URL url = file.toURI().toURL();
Resource in classpath using classloader
URL url = MyClass.class.getClassLoader().getResource("resource_name")
When I need to read the content, I can use the following code:
InputStream stream = url.openStream();
And you can access the content using an InputStream.