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