Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Is there a function similar to C++'s sprintf

Reply
Thread Tools

Is there a function similar to C++'s sprintf

 
 
Pep
Guest
Posts: n/a
 
      08-23-2005
I need to create a string from a number of variables taht in C++ I
would normally use sprintf something like sprintf(target_string,
formatting_string, variable1, variable2, ...)

I know that in java 1.5.0 the string class has a formatter but I cannot
find anything like this in 1.4.2

So it looks like I am going to have to write a helper function using
StringBuffer?

TIA,
Pep.

 
Reply With Quote
 
 
 
 
James
Guest
Posts: n/a
 
      08-23-2005
Have a look at java.text.MessageFormat. It is not as convenient as 1.5
as you have to put the arguments into an array first, but it does the
job.

 
Reply With Quote
 
 
 
 
Boudewijn Dijkstra
Guest
Posts: n/a
 
      08-23-2005
"Pep" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) oups.com...
>I need to create a string from a number of variables taht in C++ I
> would normally use sprintf something like sprintf(target_string,
> formatting_string, variable1, variable2, ...)
>
> I know that in java 1.5.0 the string class has a formatter but I cannot
> find anything like this in 1.4.2
>
> So it looks like I am going to have to write a helper function using
> StringBuffer?


Some other people have already done that for pre-1.5. I don't know who did it
or what's it called, though.


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-23-2005
On 23 Aug 2005 03:30:29 -0700, "Pep" <(E-Mail Removed)> wrote or
quoted :

>
>I know that in java 1.5.0 the string class has a formatter but I cannot
>find anything like this in 1.4.2


There is nothing from sun, but if you scan the web you should find
lots of home brew attempts at it.

Every C programmer coming to Java figures it is impossible to code
without it.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com
 
Reply With Quote
 
Pep
Guest
Posts: n/a
 
      08-25-2005
I don't know about impossible but it is certainly a very useful aspect
of string handling that Java lacks pre 1.5.

As it is I have managed to convince the powers that be that i can use
1.5 so my initial problem has gone away though the java implementation
is a bit raw compared to C/C++ string formatting.

Cheers,
Pep.

 
Reply With Quote
 
Joan
Guest
Posts: n/a
 
      08-25-2005

"Pep" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>I don't know about impossible but it is certainly a very useful
>aspect
> of string handling that Java lacks pre 1.5.
>
> As it is I have managed to convince the powers that be that i
> can use
> 1.5 so my initial problem has gone away though the java
> implementation
> is a bit raw compared to C/C++ string formatting.
>
> Cheers,
> Pep.


In particular, what is it that is irritating you?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does ModelSim or any simulator software have a function similar tothe standard function any logic analizer has? Weng Tianxiang VHDL 7 09-11-2009 04:47 PM
Any similar Webcam broadcasting site similar to youtube Chaudhry Nijjhar Computer Support 0 02-19-2008 11:48 PM
Are there sprintf in Python??? questions? Python 5 01-26-2007 04:34 PM
difficulties with sprintf function Pilatus C++ 3 12-18-2003 07:00 PM
atoi: stringstream or old C sprintf function Mike Chirico C++ 2 11-19-2003 03:59 PM



Advertisments