This content has been marked as final. Show 3 replies
What's wrong with raf.readLong()?
brendan1976 wrote:That would depend on what is stored in the 8 bytes. Is it the binary representation of a Java long? Is it the binary representation of an unsigned number (which Java does not have)?
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; raf.read(captureTimeStamp, 0, 8);
Yes, raf.readLong does seem to do the job alright, I missed that one, Cheers.