Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Buffered Writer and Print Writer  RSS feed

 
Venki Umaashankar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys..
I need to write to a file. I am just not sure which would be a right option Buffered Writer or Print Writer?
When i should use Buffered Writer and when i should use Print Writer?
 
Vijay Dharap
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venki Umaashankar wrote:Hey Guys..
I need to write to a file. I am just not sure which would be a right option Buffered Writer or Print Writer?
When i should use Buffered Writer and when i should use Print Writer?

As mentioned in java doc for BufferedWriter, you should try to use PrintWriter with an internal BufferedWriter like shown below


 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware of calling it out; you may get confusion with System.out.
 
Venki Umaashankar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay Dharap wrote:
Venki Umaashankar wrote:Hey Guys..
I need to write to a file. I am just not sure which would be a right option Buffered Writer or Print Writer?
When i should use Buffered Writer and when i should use Print Writer?

As mentioned in java doc for BufferedWriter, you should try to use PrintWriter with an internal BufferedWriter like shown below





Thanks Vijay I got it!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!