O GoConqr está de visual novo! Conte para nós o que você achou.

Módulo 14 de 22 · Mídia

Read from a file

Kostas Diakogiannis

Read from a file

Read a file's contents

Now we have imported the fs module, we can work with files. Let's create a .txt file inside the same folder, and fill it with some text and save the file. 

We will try to read the contents of this file and log it to the console through node.js.

For that purpose we will use the fs.readFileSync function, which accepts the path of the file as an argument, and then we will log it's contents as it's shown above.

This is the synchronous way, that means that while the execution of the reading is taking place, our whole script is blocked and can't execute further.

Instruções

Para avançar no curso, envie uma tentativa deste quiz. Você pode enviá-la depois da última pergunta.

Ir para o módulo escolhido

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?