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
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
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]
Squanch that. And squanch this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
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...