同步文件写入
var fs = require('fs')
//打开文件
var fd = fs.openSync('hello.txt', 'w')
//写入内容
fs.writeSync(fd, 'hello node')
//关闭文件
fs.closeSync(fd)
fs.openSync(path, flags[, mode])
path: 路径
flags: 要做的操作类型标识
r 只读的
w 可写的
mode: 设置文件的操作权限,一般不传
fs.writeSync(fd, string[, position[, encoding]])
fd: 要写入的文件的描述符
string: 要写入的内容
position: 起始位置
encoding: 写入所用的编码集,默认是UTF-8
fs.closeSync(fd)

浙公网安备 33010602011771号