Hacker News new | past | comments | ask | show | jobs | submit login

Look at the FileInputStream and FileOutputStream classes in Java. The finalize method in them makes sure the file is closed when the object is reclaimed, to prevent file handle leaking.

It's not particularly effective a strategy for managing file handles unfortunately and if you forget to close your output streams, your program will crash with "too many open files".




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: