File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes System.out.println Special Characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "System.out.println Special Characters" Watch "System.out.println Special Characters" New topic
Author

System.out.println Special Characters

David Dickinson
Ranch Hand

Joined: Nov 11, 2004
Posts: 66
Hi,

Does the command System.out.println have any special functions which enter tabs into the stream or anything like that? Features which would improve the formatting of the console output?

For instance I have multiple lines and wish for the information to be displayed like so..

Report xyz calculates currency exchange �-$ = $120
Report xyz calculates oil price rise to be = $110/day

Etc etc so the equals column is always level
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

You can embed a tab in a string using the escape sequence \t -- i.e.,

System.out.print("\t")

prints a tab character.


[Jess in Action][AskingGoodQuestions]
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
System.out.println( "oil price" + '\t' + "$50" );
System.out.println( "wine price" + '\t' + "$60" );

Be aware that the number of spaces between tabs could be 5, so hitting the same tab to align columns requires a bit of planning.


Mike Gershman
SCJP 1.4, SCWCD in process
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.out.println Special Characters
 
Similar Threads
columnClasses in HtmlDataTable
Question on inheritence
function-array
URGENT : Thread Problems
constructor question