c++ to Java question

I

Ike

Suppose 'ar' is a fileoutputstream, and 'label' is a String.

How would the following line be performed by us, in Java:

ar << " '" << label << "', "

Thanks, Ike
 
J

Jon A. Cruz

Joona said:
ar.write("'"+label+", ")

Or it's often more appropriate to use MessageFormat. That gives you
formatting, internationalizeation, easy changing of user-friendly text, etc.

ar.write( MessageFormat.format( "'{0}, ", new Object[]{label} ) );
 
T

Timo Kinnunen

Joona I Palaste said:
ar.write("'"+label+", ")

InputStream doesn't accept Strings, so I guess you meant

ar.write((" '" + label + ", ").getBytes(/* charset name */));
 
J

Joona I Palaste

InputStream doesn't accept Strings, so I guess you meant
ar.write((" '" + label + ", ").getBytes(/* charset name */));

Of course, assuming you meant OutputStream and not InputStream. =)

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Remember: There are only three kinds of people - those who can count and those
who can't."
- Vampyra
 
C

CN

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It makes no difference here, unless you store the "'{0}, " in some
resource bundle.

Jon A. Cruz wrote:
| Joona I Palaste wrote:
|
|>> How would the following line be performed by us, in Java:
|>
|>
|>
|>> ar << " '" << label << "', "
|>
|>
|>
|>> Thanks, Ike
|>
|>
|>
|> ar.write("'"+label+", ")
|>
|
| Or it's often more appropriate to use MessageFormat. That gives you
| formatting, internationalizeation, easy changing of user-friendly text,
| etc.
|
| ar.write( MessageFormat.format( "'{0}, ", new Object[]{label} ) );
|
|
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAdlcAgtM42grMkd0RArHfAJ48pes5CAmZIUUMJ54mwNl9IK1I8gCeNpkK
xnfFx1Gu7IfxX6/1tx074uU=
=AVW7
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top