NodeJS / NodeJS File System Module
File system module in Node.js used to work (Read, Create, Update, Delete, Rename files) with the files in the server system.
Program Name
Write a Program for NodeJS File System Module for Reading files using Filesystem object. |
Theory
Program for NodeJS File System Module for Reading files using Filesystem object
|
Program Code
|
Compiling and running
node Nodejsexample.js
|
Output
File reading Example using nodejs
|
Append text to files using Filesystem object
Program Name
Write a Program for NodeJS File System Append text to files using Filesystem object. |
Theory
Program for NodeJS File System Module for Append text to files using Filesystem object
|
Program Code
|
Compiling and running
node Nodejsexample.js
|
Output
Example.html: File reading Example using nodejsAppend text to files!
|
Explanation
Adds text to end of the file.
|
Write text to files using Filesystem object
Program Name
Write a Program for Write text to files using Filesystem object in NodeJS. |
Theory
Program for Write text to files using Filesystem object in NodeJS
|
Program Code
|
Compiling and running
node Nodejsexample.js
|
Output
Example.html: write content to file!
|
Explanation
Write: creates a file if not there and writes new content to file after removing the old content.
|
Replace text in the files using Filesystem object
Program Name
Write a Program for Replace text in the files using Filesystem object in NodeJS. |
Theory
Program for Replace text in the files using Filesystem object in NodeJS.
|
Program Code
|
Compiling and running
node Nodejsexample.js
|
Output
Example.html: written content to file!
|
Delete Files using Filesystem object in NodeJs
Program Name
Write a Program for Delete Files using Filesystem object in NodeJs. |
Theory
Program for Delete Files using Filesystem object in NodeJs.
|
Program Code
|
Compiling and running
node Nodejsexample.js
|
Output
File deleted using File system object in nodejs
Example.html: File deleted
|
Program Name
Write a Program for Rename Files using Filesystem object in NodeJs. |
Theory
Program for Rename Files using Filesystem object in NodeJs
|
Program Code
|
Compiling and running
node Nodejsexample.js
|
Output
'File Renamed using File system object in nodejs
i.e 'example.html' to 'example2.html'
|
|