Have a FileInputStream, I am wondering whether I need to close it or not? If yes, if I pass this stream object to the other method, can I close in that sub method?
Share
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.
Yes, you can close the stream in the method where you passed it.
But beware. If you use the same stream after the method call it will remain closed.
The best practice is to close the stream after you’ve done all you wanted with it.