Module Overview
This module introduces file handling in Java and explains how applications create, read, write and delete files to store and manage information.
Learners will explore the File class and understand how Java interacts with files stored in a system.
The module also covers FileReader, FileWriter, BufferedReader and BufferedWriter, helping learners understand different approaches to reading and writing text files.
These concepts are useful for developing applications that store information, process records and manage external data.
What Will Be Covered
13.1 File Class
Understanding the purpose of the File class in Java.
Creating File objects to represent file and directory paths.
Exploring methods available in the File class.
Checking whether a file or directory exists.
Retrieving file information such as name, path and location.
Understanding how Java manages file and directory references.
13.2 Create a File
Understanding how to create files using Java.
Using the createNewFile() method.
Specifying file names and paths.
Checking whether a file already exists.
Handling file creation exceptions.
Creating files as part of application data management.
13.3 Write into File
Understanding how Java writes information into files.
Exploring file output operations.
Writing text and data into files.
Managing file writing operations.
Understanding how to append information to an existing file.
Applying file writing techniques to store application records.
13.4 Read from File
Understanding how Java retrieves information from files.
Exploring different approaches to reading file contents.
Reading text from existing files.
Processing file contents line by line.
Handling file reading exceptions.
Applying file reading operations to retrieve stored information.
13.5 Delete File
Understanding how to delete files using Java.
Using the delete() method of the File class.
Checking whether a file exists before deletion.
Understanding the result of a file deletion operation.
Handling file deletion requirements within applications.
Managing unnecessary files in application environments.
13.6 FileReader
Understanding the purpose of the FileReader class.
Reading character-based data from files.
Creating FileReader objects.
Reading individual characters from a file.
Understanding character streams in Java.
Applying FileReader to retrieve text-based information.
13.7 FileWriter
Understanding the purpose of the FileWriter class.
Writing character-based data into files.
Creating FileWriter objects.
Writing text using file writing methods.
Understanding file overwrite and append modes.
Applying FileWriter to save text-based application information.
13.8 BufferedReader
Understanding the purpose of BufferedReader.
Reading text efficiently using character buffering.
Creating BufferedReader objects.
Reading individual lines using readLine().
Understanding how buffering improves reading efficiency.
Applying BufferedReader to process text files containing multiple records.
13.9 BufferedWriter
Understanding the purpose of BufferedWriter.
Writing text using buffered character streams.
Creating BufferedWriter objects.
Writing information using write() and newLine().
Understanding how buffering supports efficient file operations.
Applying BufferedWriter to write and organise application data.
Skills You Will Gain
Understanding file handling concepts in Java.
Creating and managing File objects.
Creating and deleting files.
Writing information into files.
Reading and processing file contents.
Working with FileReader and FileWriter.
Using BufferedReader and BufferedWriter.
Understanding character-based and buffered streams.
Managing file operations and related exceptions.
Storing and retrieving application information using files.
Learning Outcomes
By the end of this module, learners will be able to:
Use Java file-handling capabilities to manage external files used by business applications.
Create files to store information such as customer records, employee details and application reports.
Write application data into files for storage and future reference.
Read and process stored information to support reporting and data retrieval requirements.
Delete unnecessary files as part of application data management.
Select FileReader and FileWriter for character-based file operations.
Apply BufferedReader and BufferedWriter to process larger text files efficiently.
Develop file-handling functionality to support information storage, retrieval and record management.
Apply appropriate exception handling when performing file operations.
Certification Alignment
This module develops Java file-handling knowledge that supports the broader learning pathway towards the Oracle Certified Professional: Java SE 17 Developer certification.
The topics covered help learners understand file operations, character streams, buffered reading and writing, and file management within Java applications.
Continue to the Next Module
Continue to Module 14: Collections Framework to learn how Java stores, organises and manages groups of objects using ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap and Iterator.
Still need help?
Contact us