Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Padding will NOT work?  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain why this will not pad?? It keeps displaying normally, even if i add spaces it will not work, this is getting very frustrating lol.


This is what it is printing:

=================== =================== ====================== ===
lastname, firstname, 123-12-1234, 16

The lastname, firstname, 123-12-1234, 16 should be padded and appear with about 20 spaces between them.


 
Bartender
Posts: 1460
31
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The padding appears for me, Corey. What are you using to look at your output? Web browsers behave the way you are describing, collapsing multiple white spaces into just one space.

Might also help if you listed a bit more of the surrounding code.
 
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't say what you are using to view this "printing". If for example you use HTML to view it -- as is the case here -- then HTML is designed to compress multiple spaces into a single space, and it throws away all your hard work. So how are you looking at that output?
 
Stevens Miller
Bartender
Posts: 1460
31
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like we got it, Paul: he's marked it to be resolved.
 
Paul Clapham
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it's worth noting that not all of HTML compresses whitespace. Text which is inside a <pre> element is exempt from that rule, and all whitespace including line-endings is left as is.
 
Stevens Miller
Bartender
Posts: 1460
31
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I knew about the <pre> exception, but not the EOL exception. Thanks for the tip!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!