StandardOpenOption Enums Flashcards
How are StandardOpenOption Enums used?
With input/outputStream Readers. OutputStream out = Files.newOutputStream(tmp, StandardOpenOption.DELETE_ON_CLOSE);
If the file is opened for WRITE access then bytes will be written to the end of the file rather than the beginning is controlled using which Enum?
APPEND
Create a new file if it does not exist?
CREATE
Create a new file, failing if the file already exists.
CREATE_NEW
Delete on close.
DELETE_ON_CLOSE
Requires that every update to the file’s content be written synchronously to the underlying storage device.
DSYNC
Open for read access.
READ
When used with the CREATE_NEW option then this option provides a hint that the new file will be sparse. The option is ignored when the file system does not support the creation of sparse files.
SPARSE
Requires that every update to the file’s content or metadata be written synchronously to the underlying storage device.
SYNC
If the file already exists and it is opened for WRITE access, then its length is truncated to 0.
TRUNCATE_EXISTING
Open for write access.
WRITE
Write
Open for write access.
TRUNCATE_EXISTING
If the file already exists and it is opened for WRITE access, then its length is truncated to 0.
SYNC
Requires that every update to the file’s content or metadata be written synchronously to the underlying storage device.
SPARSE
When used with the CREATE_NEW option then this option provides a hint that the new file will be sparse. The option is ignored when the file system does not support the creation of sparse files.