Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Beginning Java
Closing a file
marlon tan
Ranch Hand
Posts: 53
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
In using
Java
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
lower.close()
or
higher.close()
, or both?
Thank you.
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The "wrapper" classes like BufferedWriter pass the close() call along to the "wrapped" object -- so calling upper.close() automatically calls lower.close() as well.
[Jess in Action]
[AskingGoodQuestions]
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
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
More...