Skip to content · ⁨דלג לתוכן⁩

Text files: write and read with Scanner · ⁨קבצי טקסט: כתיבה וקריאה עם 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.
עברית

קריאה וכתיבה בקבצי טקסט

  • קובץ טקסט מאחסן טקסט שנשאר על דיסק לאחר שהתוכנית מסתיימת.
  • כדי לקרוא קובץ ב-Java אנו משתמשים ב-Scanner שמחובר ל-File.
  • כדי לכתוב קובץ אנו משתמשים ב-PrintWriter. בשיעור זה כל תוכנית כותבת קובץ ולאחר מכן קוראת אותו חזרה.
  • שיעור נוסף: מבחן AP CSA אינו בודק כניסה/יציאה לקבצים. למד זאת לתוכניות אמיתיות — לא תבחן עליה.

Handout · ⁨חומר עזר⁩

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP