学习node4_write方法

1:fs.write(fd,buffer,offset,length,position,callback)

fd:打开的文件

buffer:要写入的数据

offerset:buffer对象中要写入数据的起始位置

Length:要写入的buffer数据的长度

position:fd中的起始位置

callback:回掉

2:fs.write写字符串

fs.write(fd,str,position,[encoding])

srt:写入的字符串

postion:fd中的起始位置

[encoding]格式

 3:fs.write的2个同步版本都没回调函数

4:fs.close(fd,callback)关闭打开的文件

 5:fs.writeFile(path,data,callback)

path:路径

data:数据

callback:回调 

如果没有这个文件,就新建,如果有则覆盖文件

原文地址:https://www.cnblogs.com/yudabing/p/6992118.html