1. Learn
  2. /
  3. Courses
  4. /
  5. Input/Output and Streams in Java

Connected

Exercise

Storing Recent Notes in Cache

To speed up access to recent notes, your app will store them in a lightweight cache file. In this task, you'll create a new file called "cache.txt" and confirm that it was successfully created. This sets the stage for saving frequently used data.

All the necessary packages from java.io have been imported for you.

Instructions

100 XP
  • Create a File object for "cache.txt".
  • Check if the file already exists.
  • If the file exists, delete it.
  • Create a new file named "cache.txt".