File Processing

IB Syllabus: B2.5 – File processing


Overview

Programs need to persist data – to save information that survives after the program ends and to load information saved by previous runs. File processing is how programs read from and write to text files on disk.

# Topic Syllabus Key Concepts Level
1 Reading Files B2.5.1 Scanner, BufferedReader, parsing lines, processing data from files SL + HL
2 Writing Files B2.5.1 FileWriter, BufferedWriter, overwrite vs append, CSV output SL + HL

When to Use Which

Task Best Approach
Read a small file with mixed types (int, String) Scanner(new File(...))
Read a large text file line-by-line BufferedReader(new FileReader(...))
Write to a file (overwrite) FileWriter("file.txt")
Append to a file FileWriter("file.txt", true)
Write efficiently with newLine() BufferedWriter(new FileWriter(...))
Always Wrap in try/catch, close the file

Table of contents


© EduCS.me — A resource hub for Computer Science education

This site uses Just the Docs, a documentation theme for Jekyll.