Node.js Tutorial for Beginners 8 - Reading and Writing Files using fs module

preview_player
Показать описание
File I/O is provided by simple wrappers around standard POSIX functions. To use this module do require('fs'). All the methods have asynchronous and synchronous forms.

The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined.

★★★Top Online Courses From ProgrammingKnowledge ★★★

★★★ Online Courses to learn ★★★

★★★ Follow ★★★

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Рекомендации по теме
Комментарии
Автор

Sir what i will do when we have data in JSON file?? How to read ??

Batman-wm
Автор

I am probably missing something very obvious but... There are tons of videos dedicated to this topic on YouTube, but nobody (at least, i was not able to find) dedicates a few seconds to explain what the prerequisites are. What kind of editor you use? Which steps to be performed to bring this screen up? Any alternative editors to recognize fs module objects? Without knowing the basics the value of the entire video is drastically deflating, since the most-straight way in learning programming is a practice.

alexm
Автор

How do I get this data in a html/js file???

cicerogomesalves
Автор

A bug here: This asynchronous method is not working as read_string var is void. So undefined is showing up on newly written file. i am not able to solve this bug. Plz help.

rishikamehta
Автор

The last example don't work for me. I get the printout ->

_the file is read_
_success!_
_I am going to write someshing._
_I am going to write someshing._
_... and so on..._

And in the test3.txt I get ->

_undefined_

daniellajohansson
Автор

var fs = require('fs');

var read_string = fs.readFileSync('pdf.txt', 'utf8');
console.log("read string");
pls help i only got the outpu of console note my .txt
file

amanchouhan