Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: How can I w...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 13 Topic 16039 of 16269
Post > Topic >>

Re: How can I write right-justified into a 12 chars width field?

by Knute Johnson <nospam@[EMAIL PROTECTED] > Apr 29, 2008 at 02:42 PM

Catherina Svensson wrote:
> Lets say I have a String var which can contain values of different
lengths e.g.
> "aaa"  or "bb bb bb".
> 
> I want to print them out with System.out.println right-justified with a
field width
> of 12 chars. If necessary this field should be left padded with blanks.
> For the samples above the output should be e.g.:
> 
> "         aaa"
> and
> "    bb bb bb"
> 
> How can I implement this right-justified, blank padded, fixed-width
filed output in Java?
> 
> Cat
> 

System.out.printf("%12s","some string");

-- 

Knute Johnson
email s/nospam/linux/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
 




 13 Posts in Topic:
How can I write right-justified into a 12 chars width field?
gremlin@[EMAIL PROTECTED]  2008-04-29 18:23:11 
Re: How can I write right-justified into a 12 chars width field?
Lord Zoltar <lord.zolt  2008-04-29 11:30:08 
Re: How can I write right-justified into a 12 chars width field?
Mark Space <markspace@  2008-04-29 14:03:30 
Re: How can I write right-justified into a 12 chars width field?
Knute Johnson <nospam@  2008-04-29 14:42:26 
Re: How can I write right-justified into a 12 chars width field?
=?ISO-8859-1?Q?Arne_Vajh=  2008-04-29 19:12:28 
Re: How can I write right-justified into a 12 chars width field?
Christian <fakemail@[E  2008-04-30 01:42:37 
Re: How can I write right-justified into a 12 chars width field?
Chase Preuninger <chas  2008-04-29 18:25:40 
Re: How can I write right-justified into a 12 chars width field?
petersprc <petersprc@[  2008-04-29 19:13:04 
Re: How can I write right-justified into a 12 chars width field?
Andrea Francia <andrea  2008-04-30 21:11:43 
Re: How can I write right-justified into a 12 chars width field?
alexandre_paterson@[EMAIL  2008-04-29 20:21:46 
Re: How can I write right-justified into a 12 chars width field?
Roedy Green <see_websi  2008-04-30 05:04:11 
Re: How can I write right-justified into a 12 chars width field?
Donkey Hot <spam@[EMAI  2008-04-30 16:48:13 
Re: How can I write right-justified into a 12 chars width field?
thufir <hawat.thufir@[  2008-04-30 22:08:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 23:10:19 CDT 2008.