---
title: "write(to:atomically:encoding:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/stringprotocol/write(to:atomically:encoding:)"
---

# write(to:atomically:encoding:)

Writes the contents of the String to the URL specified by url using the specified encoding.

## Declaration

```swift
func write(to url: URL, atomically useAuxiliaryFile: Bool, encoding enc: String.Encoding) throws
```
