fs读取某个json文件的数据

/**
 * Created by Administrator on 2016/7/12.
 * 流数据
 */
var fs = require('fs');
var stream = fs.createReadStream('./obd.json');
var data = "";
stream.on('data',function(chrunk){//将数据分为一块一块的传递
    console.log(chrunk);
    console.log(chrunk.toString());
    data += chrunk;
});
stream.on('end',function(){
    console.log(data);
    console.log(data.toString());

    console.log('finished!!!!');
});
posted @ 2016-08-30 17:37  钟离野  阅读(2782)  评论(0编辑  收藏  举报