@@ -455,7 +455,7 @@ Synchronous version of `fs.read`. Returns the number of `bytesRead`.
455
455
## fs.readFile(filename[ , options] , callback)
456
456
457
457
* ` filename ` {String}
458
- * ` options ` {Object}
458
+ * ` options ` {Object | String }
459
459
* ` encoding ` {String | Null} default = ` null `
460
460
* ` flag ` {String} default = ` 'r' `
461
461
* ` callback ` {Function}
@@ -472,6 +472,10 @@ contents of the file.
472
472
473
473
If no encoding is specified, then the raw buffer is returned.
474
474
475
+ If ` options ` is a string, then it specifies the encoding. Example:
476
+
477
+ fs.readFile('/etc/passwd', 'utf8', callback);
478
+
475
479
476
480
## fs.readFileSync(filename[ , options] )
477
481
@@ -485,7 +489,7 @@ string. Otherwise it returns a buffer.
485
489
486
490
* ` filename ` {String}
487
491
* ` data ` {String | Buffer}
488
- * ` options ` {Object}
492
+ * ` options ` {Object | String }
489
493
* ` encoding ` {String | Null} default = ` 'utf8' `
490
494
* ` mode ` {Number} default = ` 0o666 `
491
495
* ` flag ` {String} default = ` 'w' `
@@ -504,6 +508,10 @@ Example:
504
508
console.log('It\'s saved!');
505
509
});
506
510
511
+ If ` options ` is a string, then it specifies the encoding. Example:
512
+
513
+ fs.writeFile('message.txt', 'Hello io.js', 'utf8', callback);
514
+
507
515
## fs.writeFileSync(filename, data[ , options] )
508
516
509
517
The synchronous version of ` fs.writeFile ` .
@@ -512,7 +520,7 @@ The synchronous version of `fs.writeFile`.
512
520
513
521
* ` filename ` {String}
514
522
* ` data ` {String | Buffer}
515
- * ` options ` {Object}
523
+ * ` options ` {Object | String }
516
524
* ` encoding ` {String | Null} default = ` 'utf8' `
517
525
* ` mode ` {Number} default = ` 0o666 `
518
526
* ` flag ` {String} default = ` 'a' `
@@ -528,6 +536,10 @@ Example:
528
536
console.log('The "data to append" was appended to file!');
529
537
});
530
538
539
+ If ` options ` is a string, then it specifies the encoding. Example:
540
+
541
+ fs.appendFile('message.txt', 'data to append', 'utf8', callback);
542
+
531
543
## fs.appendFileSync(filename, data[ , options] )
532
544
533
545
The synchronous version of ` fs.appendFile ` .
0 commit comments