---
title: "write(toAbsoluteOffset:_:retryOnInterrupt:)"
framework: system
role: symbol
role_heading: Instance Method
path: "system/filedescriptor/write(toabsoluteoffset:_:retryoninterrupt:)"
---

# write(toAbsoluteOffset:_:retryOnInterrupt:)

Writes the contents of a buffer at the specified offset.

## Declaration

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

## Parameters

- `offset`: The file offset where writing begins.
- `buffer`: The region of memory that contains the data being written.
- `retryOnInterrupt`: Whether to retry the write operation if it throws doc://com.apple.SwiftSystem/documentation/System/Errno/interrupted. The default is true. Pass false to try only once and throw an error upon interruption.

## Mentioned in

Adopting Swift File Operations

## Return Value

Return Value The number of bytes that were written.

## Discussion

Discussion Unlike write(_:retryOnInterrupt:), this method leaves the file’s existing offset unchanged. The corresponding C function is pwrite.

## See Also

### Writing To A File

- [write(_:retryOnInterrupt:)](system/filedescriptor/write(_:retryoninterrupt:).md)
- [writeAll(_:)](system/filedescriptor/writeall(_:).md)
- [writeAll(toAbsoluteOffset:_:)](system/filedescriptor/writeall(toabsoluteoffset:_:).md)
