[Newbies] Do I need to close a FileStream?
Tim Johnson
trilobyte at hoe.nu
Sat Mar 24 16:41:14 UTC 2007
Thanks!
- Tim
On Mar 24, 2007, at 3:25 AM, Bert Freudenberg wrote:
> On Mar 24, 2007, at 8:34 , Tim Johnson wrote:
>
>> Hi,
>>
>> Do I need to worry about closing a read-only FileStream when I am
>> done reading from it?
>
> Yes. Always. A common pattern is
>
> f := ... open the file stream ....
> [ ... do something with f ... ] ensure: [f close]
>
> This ensures f is closed even if there is an error in your
> processing code.
>
>> What happens if I don't?
>
> Bad Things ;) I'm not exactly sure.
>
>> How can I tell if I have lots of open files in my system?
>> "FileStream allInstances inspect"?
>
> You would need to use #allSubInstances and check if they're open.
More information about the Beginners
mailing list