This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Unexpected Behaviour with Writers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Unexpected Behaviour with Writers" Watch "Unexpected Behaviour with Writers" New topic
Author

Unexpected Behaviour with Writers

jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Hi, I'm running he following code:



And when I run it, the output is the following:

Hello!I'm a FileWriter
I'm a BufferedWriter
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
Why is that unexpected behavior? The buffered writer buffers its output, while the straight writer writes immediately. Seems like it should be.

As an aside, I wouldn't use several writers that access the same underlying resource.


Ping & DNS - my free Android networking tools app
jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Ah ok... Buffered... figures :-) By Unexpected, I meant "that I didn't expect" of course. Thanks for the answer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unexpected Behaviour with Writers
 
Similar Threads
File IO - BufferedWriter/FileWriter
Stringbuffer and carriage return
how to see how control is moving in a java program during execution
Printing from threads in a particular sequence
Search and Replace tag (Not its Value) in an XML file.