Alex Rivera | Logout

Do I need to close files I perform File.getName() on?

Asked 2011-11-21T12:26:30.657
17

I'll be having lot of files in a directory. I'll be just getting the file names using File.getName() and log them to a log file. I presume, I don't need to close the file since I'm not doing any read/write operation in it.

Is this correct?

Edit
Report

1 Answer

0

Yes, that's correct. When you open a file by creating a FileInputStream or a FileOutputStream, you must close the stream at the end.

answered 2011-11-21T12:29:05.807

Your Answer