Reading from a File

const fs = require('fs');

// Read the file 'example.txt'
fs.readFile('example.txt', 'utf8', (error, data) => {
  if (error) {
    console.log("Error reading file:", error);
  } else {
    // Print file content to console
    console.log("File content:");
    console.log(data);
  }
});

Leave a Reply

Your email address will not be published. Required fields are marked *