Total WebSite Views Count

Reading File In Node JS

How Node js read the content of a file?

Normally NodeJs reads the content of a file in non-blocking, asynchronous way. Node Js uses its fs core API to deal with files. The easiest way to read the entire content of a file in nodeJs is with fs.readFile method. Below is sample code to read a file in NodeJs asynchronously and synchronously.
Reading a file in node asynchronously/ non-blocking
var fs = require('fs'); 
fs.readFile('DATA', 'utf8', function(err, contents) {
    console.log(contents);
});
console.log('after calling readFile');
Reading a file in node asynchronously/blocking
var fs = require('fs'); 
var contents = fs.readFileSync('DATA', 'utf8');
console.log(contents);

AWS Services

AWS Services

Technology Selection & Evaluation Criteria

Technology Selection & Evaluation Criteria

Scale Cube - Scale In X Y Z Cube

Scale Cube - Scale In X Y Z Cube

Feature Post

AWS Services

About Me

About Me

Spring Cloud

Spring Cloud
Spring Cloud

Spring Cloud +mCloud Native + Big Data Archittect

Spring Cloud +mCloud Native + Big Data Archittect

ACID Transaction

ACID Transaction

Data Pipe Line Stack

Data Pipe Line Stack

Popular Posts