Added in API level 26

OpenOption

interface OpenOption
LinkOption

Defines the options as to how symbolic links are handled.

StandardOpenOption

Defines the standard open options.

LinkOption.NOFOLLOW_LINKS

Do not follow symbolic links.

StandardOpenOption.APPEND

If the file is opened for WRITE access then bytes will be written to the end of the file rather than the beginning.

StandardOpenOption.CREATE

Create a new file if it does not exist.

StandardOpenOption.CREATE_NEW

Create a new file, failing if the file already exists.

StandardOpenOption.DELETE_ON_CLOSE

Delete on close.

StandardOpenOption.DSYNC

Requires that every update to the file's content be written synchronously to the underlying storage device.

StandardOpenOption.READ

Open for read access.

StandardOpenOption.SPARSE

Sparse file.

StandardOpenOption.SYNC

Requires that every update to the file's content or metadata be written synchronously to the underlying storage device.

StandardOpenOption.TRUNCATE_EXISTING

If the file already exists and it is opened for WRITE access, then its length is truncated to 0.

StandardOpenOption.WRITE

Open for write access.

An object that configures how to open or create a file.

Objects of this type are used by methods such as newOutputStream, java.nio.file.Files#newByteChannel, java.nio.channels.FileChannel#open, and java.nio.channels.AsynchronousFileChannel#open when opening or creating a file.

The StandardOpenOption enumeration type defines the standard options.

Summary