“WriteFile di Node JS” 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

Menulis ke File di Node JS


const fs = require('fs')

const content = 'Some content!'

try {
  fs.writeFileSync('/Users/joe/test.txt', content)
  //file written successfully
} catch (err) {
  console.error(err)
}
Thoughtful Tern

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

WriteFile di Node JS

fs.writeFile('2pac.txt', 'Some other lyric', 'ascii', callback);
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 “WriteFile di Node JS”

Pertanyaan yang mirip dengan “WriteFile di Node JS”

Lebih banyak jawaban terkait untuk “WriteFile di Node JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya