• Post Reply Bookmark Topic Watch Topic
  • New Topic

BufferedWriter  RSS feed

 
Tharpa Roberts
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am maintaining a program and I came across a line, and I am wondering if I can safely remove a line of code.

It is only the second line I wish to remove. I include it just for context.



The thing that seems odd to me is that the new Buffered Writer is not assigned to an object. Is there any point to creating a new BufferedWriter if it is not assigned to an object?
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The line does one thing - it creates the file if it doesn't exist, or (probably) truncates the file if it does. The wrapping in OutputStreamWriter and BufferedWriter is completely unnecessary though.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!