# Easier way to write an array(Uint8)

**URL:** <https://forum.crystal-lang.org/t/easier-way-to-write-an-array-uint8/5565>\
**Category:** Crystal Contrib\
**Created:** [April 14, 2023, 4:49am UTC](https://forum.crystal-lang.org/t/easier-way-to-write-an-array-uint8/5565 "2023-04-14T04:49:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rogerdpack/32/117_2.png) [@rogerdpack](https://forum.crystal-lang.org/u/rogerdpack)\
**Post date:** [April 14, 2023, 4:49am UTC](https://forum.crystal-lang.org/t/easier-way-to-write-an-array-uint8/5565/1 "2023-04-14T04:49:17Z")

</div>

Hello.  
It seems like it should be straight forward to write Bytes to a File.

```
outy = Array(UInt8).new
File.open("abc", "w").write(outy)
```

But it yields this:

```
Error: expected argument #1 to 'File#write' to be Slice(UInt8), not Array(UInt8)
```

Apparently requiring some extra work (and magic) [to use](https://stackoverflow.com/a/35258960/32453). There is also a write\_bytes method but it also yields `Error: undefined method 'to_io' for Array(UInt8)`

Might be nice to make this easier. Cheers!
