Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ setw in java?

1,639 views
Skip to first unread message

henk53

unread,
Jul 5, 2004, 8:51:14 AM7/5/04
to
Hi what is the equivalent to the C++ setw() function in java?

thanks
henk

Tor Iver Wilhelmsen

unread,
Jul 5, 2004, 9:23:05 AM7/5/04
to
henk...@hotmail.com (henk53) writes:

> Hi what is the equivalent to the C++ setw() function in java?

Java doesn't have C++'s iostreams. What is it you actually need to
accomplish?

henk53

unread,
Jul 6, 2004, 4:23:55 PM7/6/04
to
Tor Iver Wilhelmsen <tor.iver....@broadpark.no> wrote in message news:<un02et...@broadpark.no>...

Print strings in 'neat' columns to a mono-spaced text output. Nothing
fancy really; it just needs to fill up a string with spaces up to the
given width, or give the orginal string back if it's equal or larger
than the given size.

It's a utility function of no more than a few lines, but I don't
really like to sprinkle my code with such utility funtions if there is
an alternative available in the standard libray. Unfortunately, there
seems to be none...

Roedy Green

unread,
Jul 6, 2004, 8:28:57 PM7/6/04
to
On 6 Jul 2004 13:23:55 -0700, henk...@hotmail.com (henk53) wrote or
quoted :

>
>Print strings in 'neat' columns to a mono-spaced text output. Nothing
>fancy really; it just needs to fill up a string with spaces up to the
>given width, or give the orginal string back if it's equal or larger
>than the given size.

Misc.rightPad and brothers downloadable as part of
http://mindprod.com/products.html#BUS

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Tor Iver Wilhelmsen

unread,
Jul 7, 2004, 2:51:48 AM7/7/04
to
henk...@hotmail.com (henk53) writes:

> Print strings in 'neat' columns to a mono-spaced text output. Nothing
> fancy really; it just needs to fill up a string with spaces up to the
> given width, or give the orginal string back if it's equal or larger
> than the given size.

Look into java.text.MessageFormat.

0 new messages