“fs.unlink” Kode Jawaban

fs.writefile

const fs = require('fs');

fs.writeFile("/tmp/test", "Hey there!", function(err) {
    if(err) {
        return console.log(err);
    }
    console.log("The file was saved!");
}); 

// Or
fs.writeFileSync('/tmp/test-sync', 'Hey there!');
Jeff Spicoli

NodeJS ReadFile

const fs = require('fs');

fs.readFile('/Users/joe/test.txt', 'utf8' , (err, data) => {
  if (err) {
    console.error(err);
    return
  }
  console.log(data);
});
Light Locust

fs.unlink

fs.unlink(“fileName”, function (err) {
  if (err) throw err;
  console.log(delete!');
});
Ofir Salem

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya