Valfolder =Temporaryfolder() folder.Create()ValFile = folder.NewFile("Test.dat")//Create a mappedbytebuffer with a 20-byte capacityValBuffer = randomaccessfile (file,"RW") .Channel.Map(FileChannel.Mapmode.Read_write,0, -)ValLV = 0x1122334455667788lValVL = 0x1020304050607080lbuffer.Putlong(LV)//Storage of the first longBuffer.Putlong(VL)//Store a second longBuffer. Force()//Store data to diskAssert.assertequals(0x11.ToByte(), buffer.Get(0))//Read First byteAssert.assertequals(0x3344.Toshort(), buffer.Getshort(2))//Read a shortAssert.assertequals(0x10.ToByte(), buffer.Get(8))//Read the first byte of a second longAssert.assertequals(0x3040.Toshort(), buffer.Getshort(Ten))//Read a short of the second long
From the test code above, it can be seen that the Mappedbytebuffer store long, starting from the highest bit byte of long storage , which is very similar to our written numbers. So be aware of this when operating the Mappedbytebuffer.
Mappedbytebuffer Store Long