Mappedbytebuffer Store Long

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.