Initializer

init(contentsOfFile:encoding:)

Produces a string created by reading data from the file at a given path interpreted using a given encoding.

Declaration

init(contentsOfFile path: String, encoding enc: String.Encoding) throws

See Also

Creating a String from a File or URL

init(contentsOf: URL, encoding: String.Encoding)

Produces a string created by reading data from a given URL interpreted using a given encoding. Errors are written into the inout error argument.

init(contentsOf: URL, usedEncoding: inout String.Encoding)

Produces a string created by reading data from a given URL and returns by reference the encoding used to interpret the data. Errors are written into the inout error argument.

init(contentsOfFile: String, usedEncoding: inout String.Encoding)

Produces a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.