阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js fsPromises.readFile

      Node.js fsPromises.readFile(path[, options])

      新增于: v10.0.0

      • path < string> | < Buffer> | < URL> |filename or FileHandle
      • options < Object> | < string>
        • encoding < string> | < null> Default: null
        • flag < string> See support of file system flags. Default: ‘r’.
      • Returns:

      Asynchronously reads the entire contents of a file.

      The Promise is resolved with the contents of the file. If no encoding is specified (using options.encoding), the data is returned as a Buffer object. Otherwise, the data will be a string.

      If options is a string, then it specifies the encoding.

      When the path is a directory, the behavior of fsPromises.readFile() is platform-specific. On macOS, Linux, and Windows, the promise will be rejected with an error. On FreeBSD, a representation of the directory’s contents will be returned.

      Any specified FileHandle has to support reading.


      更多内容请参考:Node.js fs 文件系统,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录