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 to Byte conversion and back yield different results

807607Dec 9 2006 — edited Dec 10 2006
Hi,

while programming with the Java Cryptography API, I stumbled across this problem:
"blah".getBytes()
and
new String("blah".getBytes()).getBytes()
yield different results.

Why is that? I tried using explicit charset conversion, but always with the same result. Shouldn't these two byte arrays match?! I must be missing something.

Thanks in advance,
Matthias
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2007
Added on Dec 9 2006
4 comments
1,034 views