“fs.WriteFile” Code-Antworten

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

Daten nicht in Dateiknoten Js schreiben

const fs = require('fs');

fs.readFile('file.txt', 'utf-8', (err, data) => {
    if(err) {
        throw err;
    }
    console.log(data);
});
Disgusted Dragonfly

fs.Readfile

fs.readFile('filename', function read(err, data) {
    if (err) {
        throw err;
    }
    var content = data;
  
    console.log(content);  
   
});
If-dev

Writefile im Knoten 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 im Knoten JS

fs.writeFile('2pac.txt', 'Some other lyric', 'ascii', callback);
Testy Tamarin

Ähnliche Antworten wie “fs.WriteFile”

Fragen ähnlich wie “fs.WriteFile”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen