• Post Reply Bookmark Topic Watch Topic
  • New Topic

Very basic question on PrintWriter println method

 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I have a very basic question on the usage of PrintWriter println method. I know from the API that println would append a new line character when used. But when I executed the below code


I was expecting the values to be printed on new line for every println. But it is actually printing all the values on the same line with out any new line character.

Just to be curious I tried to print System.getProperty("line.seperator"); but it did not print anything. Does it mean, line seperator is not set and should that be set explicitly.

If so why System.out.println on a standalone application prints on new line everytime.

What is that I'm missing here ?
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're looking at the response in your browser as an HTML page, keep in mind that newlines are considered white space in HTML and wouldn't be shown. Try looking at the source of the rendered page (how to do this depends on the browser, but try right-clicking on the page and look for a "view page source" or similar option).

One way to create a line break in HTML is to use the <br> tag, but how you format your HTML is probably better taken to a form dedicated to such things.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!