I've an application that reads/writes to some text files. When it came to packaging the application into a jar file I could not access the resources (text files) of my application using this code:
URL url = Class.forName("someclass").getResource("/resources/text/somefile.txt");
String resourcePath = url.toURI().getPath();
InputStream stream = new FileInputStream(new File(resourcePath));
Fortunately, I could easily replace it with this code:
InputStream stream = Class.forName("someclass").getResourceAsStream("/resources/text/somefile.txt");
However, I failed to find a way to get the same file into an OutputStream to be able to write to it.
Any suggestion please?