Skip to content · ⁨Pular para o conteúdo⁩

Text files: write and read with Scanner · ⁨Arquivos de texto: escrever e ler com Scanner⁩

English

Reading and writing text files

  • A text file stores text that stays on disk after the program ends.
  • To read a file in Java we use a Scanner connected to a File.
  • To write a file we use a PrintWriter. In this lesson each program writes a file, then reads it back.
  • Bonus lesson: the AP CSA exam does not test file input/output. Learn this for real programs — you will not be examined on it.
Português

Lendo e escrevendo arquivos de texto

  • Um arquivo de texto armazena texto que permanece em disco após o programa terminar.
  • Para ler um arquivo em Java usamos um Scanner conectado a um File.
  • Para escrever um arquivo usamos um PrintWriter. Nesta aula cada programa escreve um arquivo, depois lê ele de volta.
  • Aula bônus: a prova AP CSA não testa entrada/saída de arquivos. Aprenda isso para programas reais — você não será avaliado nisso.

Handout · ⁨Material de apoio⁩

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP