5,337
edits
Line 50: | Line 50: | ||
// Read an entire text file as a string | // Read an entire text file as a string | ||
fs.readFileSync('temp.txt', 'utf8'); | fs.readFileSync('temp.txt', 'utf8'); | ||
</syntaxhighlight> | |||
===Writing to a file=== | |||
[https://nodejs.org/api/fs.html Reference]<br> | |||
<syntaxhighlight lang="javascript"> | |||
const fs = require('fs-extra'); | |||
let pw = 'My_password_is_kkk'; | |||
// write to a new file named 2pac.txt | |||
fs.writeFileSync('pw.txt', pw); | |||
</syntaxhighlight> | </syntaxhighlight> | ||