@@ -482,6 +482,19 @@ or +node.RAW+.
482
482
- on success: returns +data, bytes_read+, what was read from the file.
483
483
- on error: no parameters.
484
484
485
+ +node.fs.cat(filename, encoding)+::
486
+
487
+ Outputs the entire contents of a file. Example:
488
+ +
489
+ --------------------------------
490
+ node.fs.cat("/etc/passwd", "utf8").addCallback(function (content) {
491
+ puts(content);
492
+ });
493
+ --------------------------------
494
+ +
495
+ - on success: returns +data+, what was read from the file.
496
+ - on error: no parameters.
497
+
485
498
486
499
==== +node.fs.File+
487
500
@@ -498,6 +511,18 @@ file.write("world");
498
511
file.close();
499
512
----------------------------------------
500
513
514
+ Here is an example of reading the first 10 bytes from +/etc/passwd+ and
515
+ outputting it to +stdout+.
516
+
517
+ ----------------------------------------
518
+ var file = new node.fs.File({encoding: "utf8"});
519
+ file.open("/etc/passwd", "r");
520
+ file.read(10).addCallback(function (chunk) {
521
+ puts(chunk);
522
+ });
523
+ file.close();
524
+ ----------------------------------------
525
+
501
526
[cols="1,2,10",options="header"]
502
527
|=========================================================
503
528
|Event |Parameters | Notes
0 commit comments