aspose file tools*
The moose likes Beginning Java and the fly likes print tab help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "print tab help" Watch "print tab help" New topic
Author

print tab help

Ellen fish
Greenhorn

Joined: Oct 28, 2008
Posts: 27
Hello,
when I do:
System.out.println("out.txts\t\t"+"asdf");
System.out.println("out.txt\t\t"+"asdf");

I get:
out.txtsasdf
out.txtasdf

Is there a way to align the two print result without adding an extra \t for out.txt?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

Check out PrintStream's printf method.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ellen fish
Greenhorn

Joined: Oct 28, 2008
Posts: 27
mm..printf doesn't seem to help.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39855
    
  28
Yes, it would, if you used the numbers which set the width of the fields. There are full details in Formatter, and details you can actually understand ( ) in the Java Tutorials.
Ellen fish
Greenhorn

Joined: Oct 28, 2008
Posts: 27
hm...another thing I forgot to mention is that I'm using
StringBuffer str = new StringBuffer();
and str.append to connect all the strings together and print out in the end.
I have tried but still couldn't find a way with formater ><
 
Consider Paul's rocket mass heater.
 
subject: print tab help