• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printwriter  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this line does not print new line:


Why?

and when we have classes like datainputstream and dataoutputstream that covers different datas, Why do you use Printwriter class?What is the main usage of Printwriter?
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have to refer you to the Java® Tutorials (try the character streams section) about PrintWriter. Basically, you need to distinguish between writers and readers for characters (text‑based files) and bytes (non‑text files or binary files). Go through the whole Tutorials trail and that should explain everything.
You may be missing line ends because you are using \n which is the wrong line end for Windows®. Don't use \n even though you find it in many books. If you look through the PrintWriter ←link documentation you see it may not flush automatically even with \n. Use println instead of print.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!