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!

String.getBytes() function

807603Oct 30 2007 — edited Oct 30 2007
I am looking to pass byte arrays over a socket and since the application I am developing is rather high performance, I would like to do it as efficiently as possible

My problem is that in java.lang.String class the getBytes() function accepts a String as a the parameter and returns a byte array, which means everytime i want to convert a string to a byte array it will create a new byte array.

What I would prefer would be to pass the getBytes function a String AND a byte array, then have it place the string into the byte array and return nothing (void)

There appears to be a method that does this but it is depreciated, so I was wondering if anyone knew what is going on behind the scenes so I could write my own or if there is something that I am missing

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2007
Added on Oct 30 2007
7 comments
1,364 views