File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Closing a file
Joined: Feb 18, 2001
Jun 23, 2004 11:05:00
IO classes, you often wrap lower level input/output stream to a higher level one. For example,
FileWriter lower = new FileWriter(filename); BufferedWriter higher = new BufferedWriter(osw);
What's the appropriate way of closing the file, do you close the file using
, or both?
author and iconoclast
Joined: Jul 08, 2003
Jun 23, 2004 11:36:00
The "wrapper" classes like
pass the close() call along to the "wrapped" object -- so calling upper.close() automatically calls lower.close() as well.
[Jess in Action]
I agree. Here's the link:
subject: Closing a file
Writing to a directory in a Unix environment
How to parse an XML document containing Chinese characters and get an XML bean
Couldn't move file just created earlier in the same program
Trouble appending new data to an existing file
Opening files in append mode
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015