# Writing to Files

Writing to files is similar to reading from files. Since we are accessing the file system, we must wrap our actions in a `try...catch` block.

Updated: November 16, 2026

## [Working with the FileStream](https://www.ask-codey.com/courses/java-full-stack-bootcamp/topics/working-with-the-filestream)

1. [FileStream Defaults](https://www.ask-codey.com/lessons/working-with-the-filestream-filestream-defaults) (Journeyman): Writing to a file with a \`PrintWriter\`, which by default replaces the file or creates a new one.
2. [Appending to a File](https://www.ask-codey.com/lessons/working-with-the-filestream-appending-to-a-file) (Journeyman): How to add lines to the end of a file by opening a \`FileOutputStream\` in append mode.

## [Logging Exceptions](https://www.ask-codey.com/courses/java-full-stack-bootcamp/topics/logging-exceptions)

1. [Logging Exceptions: an overview](https://www.ask-codey.com/lessons/logging-exceptions-an-overview) (Journeyman): Why applications usually write logs to text files rather than a database, before we build a simple logger.
2. [Creating the LogService](https://www.ask-codey.com/lessons/logging-exceptions-creating-the-logservice) (Journeyman): Building a small LogService that appends time-stamped messages to one log file per day.
3. [Writing Log Entries](https://www.ask-codey.com/lessons/logging-exceptions-writing-log-entries) (Journeyman): Using one LogService for error logs and another for application logs, each writing to its own directory.

Source: https://www.ask-codey.com/courses/java-full-stack-bootcamp/chapters/writing-to-files
