final
This commit is contained in:
13
task8/1/app.js
Normal file
13
task8/1/app.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const fs = require('fs');
|
||||
|
||||
// асинхронное чтение
|
||||
fs.readFile('hello.txt', 'utf8', function (error, data) {
|
||||
console.log('Асинхронное чтение файла');
|
||||
if (error) throw error; // если возникла ошибка
|
||||
console.log(data); // выводим считанные данные
|
||||
});
|
||||
|
||||
// синхронное чтение
|
||||
console.log('Синхронное чтение файла');
|
||||
let fileContent = fs.readFileSync('hello.txt', 'utf8');
|
||||
console.log(fileContent);
|
||||
1
task8/1/hello.txt
Normal file
1
task8/1/hello.txt
Normal file
@@ -0,0 +1 @@
|
||||
Hello Node JS!
|
||||
Reference in New Issue
Block a user