---
title: bytes
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/filehandle/bytes
---

# bytes

The file’s contents, as an asynchronous sequence of bytes.

## Declaration

```swift
var bytes: FileHandle.AsyncBytes { get }
```

## Discussion

Discussion Use the for-await-in syntax to iterate over the bytes in this sequence. For text files, you can also use its characters, unicodeScalars, or lines properties to retrieve the contents in a more convenient format. Since all of these properties conform to AsyncSequence, as does bytes itself, you can use methods defined by AsyncSequence to perform powerful inline processing. For example, you can skip the first n bytes of the file with myFileHandle.bytes.prefix(n). tip: Rather than creating a FileHandle to read a file asynchronously, you can instead use a file:// URL in combination with the resourceBytes property in URL.

## See Also

### Reading from a file handle asynchronously

- [FileHandle.AsyncBytes](foundation/filehandle/asyncbytes.md)
