-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_builtin_module_fs.js
More file actions
23 lines (18 loc) · 1.02 KB
/
06_builtin_module_fs.js
File metadata and controls
23 lines (18 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// const {readFileSync , writeFileSync}=require("fs")
// const path=require("path")
// const dataone=readFileSync(path.resolve(__dirname,"files","userfiles","textone.txt"),{encoding:"utf-8"});
// const datatwo=readFileSync(path.resolve(__dirname,"files","userfiles","texttwo.txt"),{encoding:"utf-8"});
// console.log(dataone);
// console.log(datatwo);
// writeFileSync(path.resolve(__dirname,"files","userfiles","textthree.txt"),`adding data to the file:${dataone}, ${datatwo}`,{flag:'a'});
const { readFile, writeFile } = require("fs")
const path = require("path")
readFile(path.resolve(__dirname, "files", "userfiles", "textone.txt"), { encoding: "utf-8" }, (err, result) => {
readFile(path.resolve(__dirname, "files", "userfiles", "texttwo.txt"), { encoding: "utf-8" }, (err, data) => {
console.log(result);
console.log(data);
writeFile(path.resolve(__dirname, "files", "userfiles", "textfour.txt"), `${result}+${data}`, { flag: "a" }, (err, writeresult) => {
console.log(writeresult);
})
})
})