巨杉数据库Sequoiadb在sdb-shell中如何对文件追加写

51次阅读

共计 420 个字符,预计需要花费 2 分钟才能阅读完成。

【问题描述】
在 sdb shell 中能否对已有文件进行追加写?

【解决方法】
1、可以使用 seek 方式对已有的文件偏移到某个位置,使用 write 从偏移的位置开始写,比如:
var file = new File(“/opt/text.txt”) // 打开文件

file.seek(0,’e’) // 表示当前 file 指针到文件末尾
file.write(“test”) // 表示从文件末尾开始写入“test”
file.close // 进行保存;
2、seek(offset,where) ,offset: 文件指针以字节为单位的偏移; where: 规定开始计算的位置,where 取值:‘b’、’c’、’e’,分别代表 Begin Current End;
3、sdb shell 中可以使用 help 方法查看相关用法,比如:new File(“/opt/text.txt”).help();
4、更多 File 的使用,请查看官方文档:
http://doc.sequoiadb.com/cn/i…。

正文完
 0