Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
  • Tim Holloway
  • Piet Souris
  • Frits Walraven


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

this line does not print new line:


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?
Posts: 68108
  • 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.
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!