893N/A/*
2362N/A * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
893N/A *
893N/A * This code is free software; you can redistribute it and/or modify it
893N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
893N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
893N/A *
893N/A * This code is distributed in the hope that it will be useful, but WITHOUT
893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
893N/A * version 2 for more details (a copy is included in the LICENSE file that
893N/A * accompanied this code).
893N/A *
893N/A * You should have received a copy of the GNU General Public License version
893N/A * 2 along with this work; if not, write to the Free Software Foundation,
893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
893N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
893N/A */
893N/A
893N/Apackage java.nio.file;
893N/A
893N/A/**
893N/A * Defines the standard open options.
893N/A *
893N/A * @since 1.7
893N/A */
893N/A
893N/Apublic enum StandardOpenOption implements OpenOption {
893N/A /**
893N/A * Open for read access.
893N/A */
893N/A READ,
893N/A
893N/A /**
893N/A * Open for write access.
893N/A */
893N/A WRITE,
893N/A
893N/A /**
893N/A * If the file is opened for {@link #WRITE} access then bytes will be written
893N/A * to the end of the file rather than the beginning.
893N/A *
893N/A * <p> If the file is opened for write access by other programs, then it
893N/A * is file system specific if writing to the end of the file is atomic.
893N/A */
893N/A APPEND,
893N/A
893N/A /**
893N/A * If the file already exists and it is opened for {@link #WRITE}
893N/A * access, then its length is truncated to 0. This option is ignored
893N/A * if the file is opened only for {@link #READ} access.
893N/A */
893N/A TRUNCATE_EXISTING,
893N/A
893N/A /**
893N/A * Create a new file if it does not exist.
893N/A * This option is ignored if the {@link #CREATE_NEW} option is also set.
893N/A * The check for the existence of the file and the creation of the file
893N/A * if it does not exist is atomic with respect to other file system
893N/A * operations.
893N/A */
893N/A CREATE,
893N/A
893N/A /**
893N/A * Create a new file, failing if the file already exists.
893N/A * The check for the existence of the file and the creation of the file
893N/A * if it does not exist is atomic with respect to other file system
893N/A * operations.
893N/A */
893N/A CREATE_NEW,
893N/A
893N/A /**
893N/A * Delete on close. When this option is present then the implementation
893N/A * makes a <em>best effort</em> attempt to delete the file when closed
893N/A * by the appropriate {@code close} method. If the {@code close} method is
893N/A * not invoked then a <em>best effort</em> attempt is made to delete the
893N/A * file when the Java virtual machine terminates (either normally, as
893N/A * defined by the Java Language Specification, or where possible, abnormally).
893N/A * This option is primarily intended for use with <em>work files</em> that
893N/A * are used solely by a single instance of the Java virtual machine. This
893N/A * option is not recommended for use when opening files that are open
893N/A * concurrently by other entities. Many of the details as to when and how
893N/A * the file is deleted are implementation specific and therefore not
893N/A * specified. In particular, an implementation may be unable to guarantee
893N/A * that it deletes the expected file when replaced by an attacker while the
893N/A * file is open. Consequently, security sensitive applications should take
893N/A * care when using this option.
893N/A *
893N/A * <p> For security reasons, this option may imply the {@link
893N/A * LinkOption#NOFOLLOW_LINKS} option. In other words, if the option is present
893N/A * when opening an existing file that is a symbolic link then it may fail
893N/A * (by throwing {@link java.io.IOException}).
893N/A */
893N/A DELETE_ON_CLOSE,
893N/A
893N/A /**
893N/A * Sparse file. When used with the {@link #CREATE_NEW} option then this
893N/A * option provides a <em>hint</em> that the new file will be sparse. The
893N/A * option is ignored when the file system does not support the creation of
893N/A * sparse files.
893N/A */
893N/A SPARSE,
893N/A
893N/A /**
893N/A * Requires that every update to the file's content or metadata be written
893N/A * synchronously to the underlying storage device.
893N/A *
893N/A * @see <a href="package-summary.html#integrity">Synchronized I/O file integrity</a>
893N/A */
893N/A SYNC,
893N/A
893N/A /**
893N/A * Requires that every update to the file's content be written
893N/A * synchronously to the underlying storage device.
893N/A *
893N/A * @see <a href="package-summary.html#integrity">Synchronized I/O file integrity</a>
893N/A */
893N/A DSYNC;
893N/A}