Go to https://nodejs.org/dist/latest-v12.x/docs/api/fs.html then you can see oficial document of fs
Now, first we need to require the fs and store it on a const by writing const fs = require('fs')
We are going to use fs.readFileSync
I am using a song.txt
file on same folder and read file text using readFileSync
and console log it
Run it and see the magic
We are going to use writeFileSync for the writing in song.txt file
Using fs.writeFileSync(path, dataForWrite) we can write in the file, what we need to write.
After write, we need to read the data so that we can see if are able to change -
Did you used fs module before ?
You can see the graphical version here
Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !
You can read the old posts from here --
Top comments (1)
title wrong, day 10 file read and write