let path = Bundle.main.path(forResource: "textfile", ofType: "txt")
print(path!)
let url = URL(fileURLWithPath: path!)
print(url)
let contentString:String = try! String(contentsOf: url, encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
//if convert to Data
let data = contentString.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue), allowLossyConversion: false)!
print("string\(contentString)")
No comments:
Post a Comment