This content has been marked as final. Show 6 replies
Yes , it's always better to close stream object. It canl affect /corrupt file operations.
I want to know what excatly will happen when i dont close.
I did a google and saw it will result in file descriptor leak, But i was not able to find "What is file descriptor leak?" , Also i want to know any other potential performance issues with this?
It might lock the file.
Also, I accidentally forgot to close a writer the other day at work
and it caused a bug that drove me crazy. Because I never closed it
the write buffer never flushed() out completely.
What is this question about exactly? Why on earth would you not want to close the input stream once you know that the operation exists and causes problelms if it wasn't executed?
Just do it.
It was just a question , I wanted to know the implications of not closing.
1) Will below code lock the file and then not closing the connection will cause a error?
2) Does opening the file in read only mode cause the file to be locked so that it cannot be opened for reading or writing later?
FileInputStream fin = new FileInputStream(file);
Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system. A new FileDescriptor object is created to represent this file connection.
Hi,Trying to open the file can cause an error if there are too many open file descriptors.
It was just a question , I wanted to know the
implications of not closing.
1) Will below code lock the file and then not closing
the connection will cause a error?
2) Does opening the file in read only mode cause theProbably not, but it can still cause an error, see above.
file to be locked so that it cannot be opened for
reading or writing later?