3rd Program
3rd Program
js
Objective: To perform file operations such as read, write, append, and delete using Node.js.
Function: fs.writeFile()
const fs = require('fs');
// File path
if (err) {
} else {
});
When you run the file will get the following output and one file example.txt will be created in the
File_operations directry
Function: fs.readFile()
const fs = require('fs');
// File path
if (err) {
} else {
});
When you run the file will get the following output
Function: fs.appendFile()
const fs = require('fs');
// File path
if (err) {
} else {
});
When you run the file will see the folloing output
const fs = require('fs');
// File path
if (err) {
} else {
});
When you run the file will see the following output