-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStream.js
More file actions
60 lines (53 loc) · 1.28 KB
/
Stream.js
File metadata and controls
60 lines (53 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Created by xiaochaochao on 2017/6/8.
*/
var fs = require('fs');
var zlib = require('zlib');
//var readerStream = fs.createReadStream('statement.txt')
// .pipe(zlib.createGzip())
// .pipe(fs.createWriteStream('statement.txt.gz'));
//var writerStream = fs.createWriteStream('output.txt');
//
//readerStream.pipe(writerStream);
fs.createReadStream('statement.txt.gz')
.pipe(zlib.createGunzip())
.pipe(fs.createWriteStream('output.txt'));
console.log("程序执行完毕");
//var fs = require("fs");
//var data = "我是大菜鸟,www.Ghostgrain.github.io";
//
//var writerStream = fs.createWriteStream('output.txt');
//
//writerStream.write(data,'UTF8');
//
//writerStream.end();
//
//writerStream.on('finish',function(){
// console.log("写入完成");
//})
//
//writerStream.on('error', function(){
// console.log(err.stack);
//})
//
//console.log("程序完毕");
//var fs = require('fs');
//var data = '';
//
//var readerStream = fs.createReadStream('statement.txt');
//
//readerStream.setEncoding('UTF8');
//
//readerStream.on('data', function(chunk){
// data += chunk;
//})
//
//readerStream.on('end', function(){
// console.log(data);
//})
//
//readerStream.on('error', function(){
// console.log(err.stack);
//})
//
//console.log("程序执行完毕");