Just wanted to know which is the best way to read a file that may be in the classpath.
The only thing i have is a property with the path of the file. For exemple:
- filepath=classpath:com/mycompany/myfile.txt
- filepath=file:/myfolder/myfile.txt
Which is the best way to load an InputStream from that property?
You can use the URL method openStream, which returns an InputStream you can use to read your file. The URL will work for files inside and outside the JAR. Just take care to use a valid URL.