<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileHandle/bytes",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So12NSFileHandleC10FoundationE5bytesAbCE10AsyncBytesVvp"
  },
  "title" : "bytes"
}
-->

# bytes

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

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

## Discussion

Use the `for`-`await`-`in` syntax to iterate over the bytes in this sequence. For text files, you can also use its <doc://com.apple.documentation/documentation/Swift/AsyncSequence/characters>, <doc://com.apple.documentation/documentation/Swift/AsyncSequence/unicodeScalars>, or <doc://com.apple.documentation/documentation/Swift/AsyncSequence/lines> properties to retrieve the contents in a more convenient format. Since all of these properties conform to <doc://com.apple.documentation/documentation/Swift/AsyncSequence>, as does [`bytes`](/documentation/Foundation/FileHandle/bytes) itself, you can use methods defined by <doc://com.apple.documentation/documentation/Swift/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 ``doc://com.apple.foundation/documentation/Foundation/FileHandle`` to read a file asynchronously, you can instead use a `file://` URL in combination with the ``doc://com.apple.foundation/documentation/Foundation/URL/resourceBytes`` property in ``doc://com.apple.foundation/documentation/Foundation/URL``.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)