Skip to Main Content

New to Java

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!

long to byte array conversion (unsigned byte)

843789May 15 2010 — edited May 15 2010
Hello,
I found this code to convert a long into a byte array but there is a problem: byte is a signed type so I wonder if it is possible to convert back to a long. Can someone post the right code?
for (k=0;k<8;k++) bytearray[k] = (byte)(index >>> (k * 8));
Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2010
Added on May 15 2010
4 comments
1,152 views