This discussion is archived
3 Replies Latest reply: Sep 4, 2008 6:50 AM by 800323 RSS

Convert an 8 byte array to a long (or unsigned integer)

807589 Newbie
Currently Being Moderated
I'm reading a binary file using RandomAccessFile, seeking and reading chunks of bytes at a time.
The binary file has a header and i'm interested in reading 8 bytes that denotes the time stamp of the file. The time stamp is 64 bits (8 bytes) long and represents the number of milliseconds since epoch (January 1st 1970).
How can I convert this byte array of 8 bytes into a long or to an unsigned integer?
RandomAccessFile raf = new RandomAccessFile(binaryDataFile, "r");
raf.seek(offsetCounter);
byte[] captureTimeStamp = new byte[8];
raf.read(captureTimeStamp, 0, 8);