Skip to Main Content

Java APIs

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!

newbie needhing help: string .getbytes returns un-understood bytes! help?

843810May 21 2008 — edited May 25 2008
Hello, I've gone nuts searching for a string to byte array function. The getBytes seemed to fill the bill, but I end up with extra bytes in the byte array. Here's the code snippet:

String sx = "012345678901234567890";
byte[] x = new byte[ sx.length()];
try {
x = sx.getBytes("ASCII");
} catch (Exception e) {System.out.println("geBytes error: " + e);}

results when I loop through the array and output as char:

[B@1fb8ee3
012345678901234567890

Could anybody explain to me why and what the "[B@1fb8ee3" really is? Is there another method to getting a byte[] from a string?

Thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2008
Added on May 21 2008
2 comments
326 views