I am aware of the getResourceAsStream() method but there is an issue with the parser that reads the file, the whole structure was implemented to expect a FileInputStream() and the getResourceAsStream() returns an input stream which cannot be casted. Is there any easy “fix” for this situation?
I am aware of the getResourceAsStream() method but there is an issue with the
Share
A resource contained within a JAR file is not itself a file, and cannot be read using a
FileInputStream. If you have code that absolutely requires aFileInputStream, then you’ll need to extract the data usinggetResourceAsStream(), copy it into a temporary file, then pass aFileInputStreamfor that temporary file to your code.Of course, in future, never write code to expect concrete implementations of things like
InputStream, you’ll always regret it.