-
Notifications
You must be signed in to change notification settings - Fork 1
Topic 06: File Processing
Zhamri Che Ani edited this page May 6, 2026
·
2 revisions
To introduce students to Java file processing concepts, including reading and writing text and binary files, handling file information, and using Java I/O stream classes for persistent data storage.
Students should be able to:
- Explain the purpose and importance of file processing in Java.
- Differentiate between text files and binary files.
- Use the
Fileclass to manage files and directories. - Apply
JFileChooserto allow users to select files. - Understand the concept of input and output streams.
- Read and write binary files using
FileInputStreamandFileOutputStream. - Read and write primitive data using
DataInputStreamandDataOutputStream. - Read and write text files using
FileReader,FileWriter,BufferedReader,PrintWriter, andScanner. - Handle file-related exceptions appropriately.
- Develop simple Java applications that perform file operations.
- Persistent data
- Secondary storage devices
- File concepts
- Text files
- Binary files
- Differences between text and binary storage
- Creating
Fileobjects - Absolute vs relative paths
- Common file methods:
exists()isFile()isDirectory()length()canRead()canWrite()getName()list()
- Opening file chooser dialog
- Selecting files and directories
- Input streams
- Output streams
- Byte-oriented vs character-oriented streams
FileInputStreamFileOutputStream- Reading and writing byte arrays
DataInputStreamDataOutputStream- Writing and reading primitive data types
FileReaderFileWriterBufferedReaderPrintWriterScanner
IOExceptionFileNotFoundException
Students create a Java program that:
- Accepts a filename from the user
- Displays:
- File name
- File size
- Read/write permission
- Whether it is a file or directory
Students develop a Java application that:
- Accepts student information from keyboard input
- Saves the data into a text file using
PrintWriter
Example:
Name: Ali
Matric No: 12345
Course: STTPK2023
Students create a program that:
- Reads all lines from a text file using
BufferedReaderorScanner - Displays the content on the console
Students develop a program that:
- Stores integer and double values into a binary file
- Reads the values back correctly using
DataInputStream
Students create a GUI application using JFileChooser that allows users to:
- Select a text file
- Display the selected file path