Title: Key Concept - File-open options
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: Learning Modules

A file may be opened using one of the following enumerated, from enum StandardOpenOptions, constants:

- WRITE – opens the file for write access.
- APPEND – appends data to the end of the file.
- TRUNCATE_EXISTING – truncates the file to zero bytes.
- CREATE_NEW – creates a new file and throws an exception if the file already exists.
- CREATE – opens the file if it exists or creates the file if it does not.
- DELETE_ON_CLOSE – deletes the file when a stream is closed.
- SPARSE – indicates that a new file will be sparse.
- SYNC and DSYNC – keeps the file contents synchronized with the underlying storage device.

The following methods, from class java.nio.file.Files, utilize the file-open options:

- newBufferedWriter
- newByteChannel
- newInputStream
- newOutputStream
- write

For additional study, view resources under:

- Level 2 Study Materials: Unit 2
- Level 2 Study Materials: Unit 3