• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printwriter

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic