-
Notifications
You must be signed in to change notification settings - Fork 0
/
input1.txt
31 lines (28 loc) · 887 Bytes
/
input1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require("fs");
const fsPromises = require("fs").promises;
// fs.readFile("file.txt", function (err, data) {
// if (err) throw err;
// console.log(data.toString());
// });
const path = require("path");
const file_ops = async () => {
try {
const data = await fsPromises.readFile(
path.join(__dirname, "utiliy.js"),
"utf8"
);
console.log(data);
} catch (err) {
console.log(err);
}
};
file_ops();
fs.readFile(path.join(__dirname, "file.txt"), function (err, data) {
if (err) throw err;
console.log(data.toString());
});
// In case you need to do multiple operations on a file, the async nature of these functions may cause semantic problems. To avoid that use async/await logic like in coreJS.
fs.writeFile(path.join(__dirname, "out.txt"), "Nice to meet", function (err) {
if (err) throw err;
console.log("Operatin finished");
});