# Module 13: File Handling

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.