I have this line in my program :
InputStream Resource_InputStream=this.getClass().getClassLoader().getResourceAsStream("Resource_Name");
But how can I get FileInputStream from it [Resource_InputStream] ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
ClassLoader#getResource()instead if its URI represents a valid local disk file system path.If it doesn’t (e.g. JAR), then your best bet is to copy it into a temporary file.
That said, I really don’t see any benefit of doing so, or it must be required by a poor helper class/method which requires
FileInputStreaminstead ofInputStream. If you can, just fix the API to ask for anInputStreaminstead. If it’s a 3rd party one, by all means report it as a bug. I’d in this specific case also put question marks around the remainder of that API.