<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/FileDescriptor/write(_:retryOnInterrupt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System14FileDescriptorV5write_16retryOnInterruptSiSW_SbtKF"
  },
  "title" : "write(_:retryOnInterrupt:)"
}
-->

# write(_:retryOnInterrupt:)

Writes the contents of a buffer at the current file offset.

```
func write(_ buffer: UnsafeRawBufferPointer, retryOnInterrupt: Bool = true) throws -> Int
```

## Parameters

`buffer`

The region of memory that contains the data being written.

`retryOnInterrupt`

Whether to retry the write operation
if it throws [`interrupted`](/documentation/System/Errno/interrupted).
The default is `true`.
Pass `false` to try only once and throw an error upon interruption.

## Return Value

The number of bytes that were written.

## Discussion

After writing,
this method increments the file’s offset by the number of bytes written.
To change the file’s offset,
call the [`seek(offset:from:)`](/documentation/System/FileDescriptor/seek(offset:from:)) method.

The corresponding C function is `write`.

---

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)