# I/O Streams for Kotlin

**URL:** <https://discuss.kotlinlang.org/t/i-o-streams-for-kotlin/9802>\
**Category:** Libraries\
**Created:** [October 11, 2018, 10:08am UTC](https://discuss.kotlinlang.org/t/i-o-streams-for-kotlin/9802 "2018-10-11T10:08:24Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![cdprete](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@cdprete](https://discuss.kotlinlang.org/u/cdprete)\
**Post date:** [July 28, 2022, 9:23am UTC](https://discuss.kotlinlang.org/t/i-o-streams-for-kotlin/9802/10 "2022-07-28T09:23:50Z")

</div>

Hi again @akornilov82.  
I’ve forked - for test purposes - and removed the `nativeByteOrder` from the method call, but I’ve now realized the situation is even more broken than expected.  
Since you handle everything either as a long, when you perform the actual write you write an entire long in BE/LE which is the cumulation of the bytes received so far, but this is wrong.  
From an API point of view, I should be able to write as BE/LE a single data type and not their cumulation to long.

For example (in BE):  
Given:

```auto
val a: UShort = 1u
val b: UShort = 2u

obs.writeUShort(a)
obs.writeUShort(b)

```

Expected result:

```auto
[0, 1, 0, 2]

```

Result got:

```auto
[0, 2, 0, 1]

```

---

_[View the full topic](https://discuss.kotlinlang.org/t/i-o-streams-for-kotlin/9802)._
