Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the size of a string in bytes

819549Apr 21 2011 — edited Apr 21 2011
Morning,

I’m trying to get the length in bytes of a string, the characters below are 3 byte UTF-8, but when I display
The length of either int, looks like is double I got 120 and I think it should be 60. Any idea



String requiredMsg = "όόόόόόόόόόόόόόόόόόόό";



int byteCountUTF8 = requiredMsg.getBytes("UTF-8").length;

int byteCountUTF8 = requiredMsg.getBytes().length;


thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2011
Added on Apr 21 2011
6 comments
496 views