Path: blob/master/src/java.base/share/classes/java/nio/file/StandardOpenOption.java
41159 views
/*1* Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio.file;2627/**28* Defines the standard open options.29*30* @since 1.731*/3233public enum StandardOpenOption implements OpenOption {34/**35* Open for read access.36*/37READ,3839/**40* Open for write access.41*/42WRITE,4344/**45* If the file is opened for {@link #WRITE} access then bytes will be written46* to the end of the file rather than the beginning.47*48* <p> If the file is opened for write access by other programs, then it49* is file system specific if writing to the end of the file is atomic.50*/51APPEND,5253/**54* If the file already exists and it is opened for {@link #WRITE}55* access, then its length is truncated to 0. This option is ignored56* if the file is opened only for {@link #READ} access.57*/58TRUNCATE_EXISTING,5960/**61* Create a new file if it does not exist.62* This option is ignored if the {@link #CREATE_NEW} option is also set.63* The check for the existence of the file and the creation of the file64* if it does not exist is atomic with respect to other file system65* operations.66*/67CREATE,6869/**70* Create a new file, failing if the file already exists.71* The check for the existence of the file and the creation of the file72* if it does not exist is atomic with respect to other file system73* operations.74*/75CREATE_NEW,7677/**78* Delete on close. When this option is present then the implementation79* makes a <em>best effort</em> attempt to delete the file when closed80* by the appropriate {@code close} method. If the {@code close} method is81* not invoked then a <em>best effort</em> attempt is made to delete the82* file when the Java virtual machine terminates (either normally, as83* defined by the Java Language Specification, or where possible, abnormally).84* This option is primarily intended for use with <em>work files</em> that85* are used solely by a single instance of the Java virtual machine. This86* option is not recommended for use when opening files that are open87* concurrently by other entities. Many of the details as to when and how88* the file is deleted are implementation specific and therefore not89* specified. In particular, an implementation may be unable to guarantee90* that it deletes the expected file when replaced by an attacker while the91* file is open. Consequently, security sensitive applications should take92* care when using this option.93*94* <p> For security reasons, this option may imply the {@link95* LinkOption#NOFOLLOW_LINKS} option. In other words, if the option is present96* when opening an existing file that is a symbolic link then it may fail97* (by throwing {@link java.io.IOException}).98*/99DELETE_ON_CLOSE,100101/**102* Sparse file. When used with the {@link #CREATE_NEW} option then this103* option provides a <em>hint</em> that the new file will be sparse. The104* option is ignored when the file system does not support the creation of105* sparse files.106*/107SPARSE,108109/**110* Requires that every update to the file's content or metadata be written111* synchronously to the underlying storage device.112*113* @see <a href="package-summary.html#integrity">Synchronized I/O file integrity</a>114*/115SYNC,116117/**118* Requires that every update to the file's content be written119* synchronously to the underlying storage device.120*121* @see <a href="package-summary.html#integrity">Synchronized I/O file integrity</a>122*/123DSYNC;124}125126127