Java – writeLong method of DataOutputStream and writing hex

file-writinghexjava

Currently, I have:

outByte.writeInt(0x49492a00); 
outByte.writeInt(0x08000000);

But i want to be able to write all of that on the same line. But:

outByte.writeLong(0x49492a0008000000)

is underlined red in Eclipse, and therefore incorrect. Is it possible to write those two lines all in one with writeLong()?

Best Answer

To use a long literal in your source code, you will need to append l or L to the constant like this:

outByte.writeLong(0x49492a0008000000L)