Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Read-entire-file/Swift/read-entire-file-1.swift
Normal file
6
Task/Read-entire-file/Swift/read-entire-file-1.swift
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
let path = "~/input.txt".stringByExpandingTildeInPath
|
||||
if let string = String(contentsOfFile: path, encoding: NSUTF8StringEncoding) {
|
||||
println(string) // print contents of file
|
||||
}
|
||||
12
Task/Read-entire-file/Swift/read-entire-file-2.swift
Normal file
12
Task/Read-entire-file/Swift/read-entire-file-2.swift
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import Foundation
|
||||
|
||||
let path = "input.txt"
|
||||
do
|
||||
{
|
||||
let string = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
|
||||
print(string) // print contents of file
|
||||
}
|
||||
catch
|
||||
{
|
||||
print("error occured: \(error)")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue