Home  >  Article  >  Web Front-end  >  Node.js method of reading files into strings_node.js

Node.js method of reading files into strings_node.js

WBOY
WBOYOriginal
2016-05-16 15:52:271099browse

The example in this article describes the method of node.js reading files into strings. Share it with everyone for your reference. The specific analysis is as follows:

Node.js is a JavaScript toolkit for writing high-performance web servers, and a series of changes began here. Uniquely, Node.js assumes you are running it in a POSIX environment, Linux or Mac OS X.

The main code is as follows:

var fs = require('fs');
var file = fs.readFileSync(path, "utf8");
console.log(file);

I hope this article will be helpful to everyone’s node.js programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn