swfit 文件读取与写入示例代码

代码语言:swift

所属分类:文件

代码描述:swfit 文件读取与写入示例代码,swift版本5.3

代码标签: 写入 示例

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

import Foundation  // Needed for those pasting into Playground

let fileName = "Test"
let dir = try? FileManager.default.url(for: .documentDirectory, 
      in: .userDomainMask, appropriateFor: nil, create: true)

// If the directory was found, we write a file to it and read it back
if let fileURL = dir?.appendingPathComponent(fileName).appendingPathExtension("txt") {

    // Write to the file named Test
    let outString = "hello swift"
    do {
        try o.........完整代码请登录后点击上方下载按钮下载查看

网友评论0

相似代码