“Menulis file di node.js” Kode Jawaban

Menulis file di node.js

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

WriteFile di Node JS

// append_file.js

const fs = require('fs');

// add a line to a lyric file, using appendFile
fs.appendFile('empirestate.txt', '\nRight there up on Broadway', (err) => {
    if (err) throw err;
    console.log('The lyrics were updated!');
});
Testy Tamarin

Tulis file di node.js

var fs = require('fs');  
var txt = '\n' + tkn_psid_id + ':' + assetUrl;
var folderName = '/duplicates/bugging/videobug/' + tkn_psid_id + '.txt';
fs.appendFile(folderName, txt, function (err) {
       if (err) {
                console.log('Append Error');
           } else {
                   console.log('DuplicateFolder' + folder);
            }
      });
Wassi

Jawaban yang mirip dengan “Menulis file di node.js”

Pertanyaan yang mirip dengan “Menulis file di node.js”

Lebih banyak jawaban terkait untuk “Menulis file di node.js” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya