I have read this post How to convert InputStream to FileInputStream on converting a InputStream into a FileInputStream. However, the answer does not work if you are using a resource that is in a jar file. Is there another way to do it.
I need to do this to get the FileChannel
from a call to
Object.class.getResourceAsStream(resourceName);
You can't, without basically writing to a file. Unless there's a file, there can't be a FileInputStream
or a FileChannel
. If at all possible, make sure your code is agnostic to the input source - design it in terms of InputStream
and ByteChannel
(or whatever kind of channel is most appropriate).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With