Skip to content

Commit 6989c62

Browse files
committed
add write file samples
1 parent 8b4920e commit 6989c62

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
// write text to 'output.txt'
4+
5+
var fs = require('fs');
6+
7+
console.log('>>> BEGIN >>>')
8+
9+
var data = 'Hello, Node.js';
10+
fs.writeFile('output.txt', data, function (err) {
11+
if (err) {
12+
console.log(err);
13+
} else {
14+
console.log('ok.');
15+
}
16+
});
17+
18+
console.log('>>> END >>>')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
// write text to 'output.txt'
4+
5+
var fs = require('fs');
6+
7+
console.log('>>> BEGIN >>>')
8+
9+
var data = 'Hello, Node.js';
10+
fs.writeFileSync('output.txt', data);
11+
12+
console.log('>>> END >>>')

0 commit comments

Comments
 (0)