# Java ByteBuffer class

**URL:** <https://ifnotnil.com/t/java-bytebuffer-class/2273>\
**Category:** General Programming\
**Created:** [14 December 2021 11:30 UTC](https://ifnotnil.com/t/java-bytebuffer-class/2273 "2021-12-14T11:30:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ventus](https://ifnotnil.com/letter_avatar_proxy/v4/letter/v/f17d59/32.png) [@Ventus](https://ifnotnil.com/u/Ventus)\
**Post date:** [14 December 2021 11:30 UTC](https://ifnotnil.com/t/java-bytebuffer-class/2273/1 "2021-12-14T11:30:03Z")

</div>

Can someone explain me the behavior of the position property of the Java ByteBuffer class. I am currently porting Java classes to Xojo and these classes make extensive use of the ByteBuffer class.

My understanding is as follows. At the creation of the class position is set to zero. Each time we write in it the position property is incremented by a value corresponding to the size of the written data. When we read a data the position property is systematically reset to zero and once the reading is done is incremented by a value corresponding to the size of the read data.

Is this correct? I confess this is a bit confusing for me. Thanks for your lights

---

<div class="post-metadata">

**Author:** ![thorstenstueker](https://ifnotnil.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@thorstenstueker](https://ifnotnil.com/u/thorstenstueker)\
**Post date:** [14 December 2021 13:15 UTC](https://ifnotnil.com/t/java-bytebuffer-class/2273/2 "2021-12-14T13:15:41Z")

</div>

It should be like you wrote but I would like to ask you if you can provide the Java Code behind to have a look on it before I say something really seriously about it.

---

<div class="post-metadata">

**Author:** ![Ventus](https://ifnotnil.com/letter_avatar_proxy/v4/letter/v/f17d59/32.png) [@Ventus](https://ifnotnil.com/u/Ventus)\
**Post date:** [14 December 2021 17:33 UTC](https://ifnotnil.com/t/java-bytebuffer-class/2273/3 "2021-12-14T17:33:16Z")

</div>

Sure. The code is public : [Java code](https://github.com/HefnySco/Mavlink2_JAVA)

In MAVLinkPacket.generateCRC I need to know the size of the payload. This is done by calling the size method of the MAVLinkPayload class. This method just returns the value of the position property.
