Skip to main content

Convert long value to byte array of size 4

2 replies [Last post]
karthik_rcs
Offline
Joined: 2006-10-27

Can any one tell me how to Convert long value to byte array of size 4

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mthornton
Offline
Joined: 2003-06-10

You need 8 bytes to represent a long value unless that long value can be cast to an int without losing information. One simple way to do such conversions is using java.nio.ByteBuffer

charlesvc
Offline
Joined: 2006-05-26

Long k = new Long(long value);
k.byteValue();