I am getting a a InputStream
from getResourceAsStream()
, and I managed to read from the file by passing the returned InputStream
to a
Not directly, no - getResourceAsStream()
is intended to return a view on read-only resources.
If you know that the resource is a writeable file, though, you can jump through some hoops, e.g.
URL resourceUrl = getClass().getResource(path);
File file = new File(resourceUrl.toURI());
OutputStream output = new FileOutputStream(file);
This should work nicely on unix-style systems, but windows file paths might give this indigestion. Try it and find out, though, you might be OK.