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

# write(_:retryOnInterrupt:)

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

## Declaration

```swift
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 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 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:) method. The corresponding C function is write.

## See Also

### Writing To A File

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