src/share/classes/java/nio/channels/FileChannel.java

Print this page




 270      * @throws  SecurityException
 271      *          If a security manager is installed and it denies an
 272      *          unspecified permission required by the implementation.
 273      *          In the case of the default provider, the {@link
 274      *          SecurityManager#checkRead(String)} method is invoked to check
 275      *          read access if the file is opened for reading. The {@link
 276      *          SecurityManager#checkWrite(String)} method is invoked to check
 277      *          write access if the file is opened for writing
 278      *
 279      * @since   1.7
 280      */
 281     public static FileChannel open(Path path,
 282                                    Set<? extends OpenOption> options,
 283                                    FileAttribute<?>... attrs)
 284         throws IOException
 285     {
 286         FileSystemProvider provider = path.getFileSystem().provider();
 287         return provider.newFileChannel(path, options, attrs);
 288     }
 289 
 290     @SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
 291     private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
 292 
 293     /**
 294      * Opens or creates a file, returning a file channel to access the file.
 295      *
 296      * <p> An invocation of this method behaves in exactly the same way as the
 297      * invocation
 298      * <pre>
 299      *     fc.{@link #open(Path,Set,FileAttribute[]) open}(file, opts, new FileAttribute&lt;?&gt;[0]);
 300      * </pre>
 301      * where {@code opts} is a set of the options specified in the {@code
 302      * options} array.
 303      *
 304      * @param   path
 305      *          The path of the file to open or create
 306      * @param   options
 307      *          Options specifying how the file is opened
 308      *
 309      * @return  A new file channel
 310      *




 270      * @throws  SecurityException
 271      *          If a security manager is installed and it denies an
 272      *          unspecified permission required by the implementation.
 273      *          In the case of the default provider, the {@link
 274      *          SecurityManager#checkRead(String)} method is invoked to check
 275      *          read access if the file is opened for reading. The {@link
 276      *          SecurityManager#checkWrite(String)} method is invoked to check
 277      *          write access if the file is opened for writing
 278      *
 279      * @since   1.7
 280      */
 281     public static FileChannel open(Path path,
 282                                    Set<? extends OpenOption> options,
 283                                    FileAttribute<?>... attrs)
 284         throws IOException
 285     {
 286         FileSystemProvider provider = path.getFileSystem().provider();
 287         return provider.newFileChannel(path, options, attrs);
 288     }
 289 
 290     @SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction
 291     private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
 292 
 293     /**
 294      * Opens or creates a file, returning a file channel to access the file.
 295      *
 296      * <p> An invocation of this method behaves in exactly the same way as the
 297      * invocation
 298      * <pre>
 299      *     fc.{@link #open(Path,Set,FileAttribute[]) open}(file, opts, new FileAttribute&lt;?&gt;[0]);
 300      * </pre>
 301      * where {@code opts} is a set of the options specified in the {@code
 302      * options} array.
 303      *
 304      * @param   path
 305      *          The path of the file to open or create
 306      * @param   options
 307      *          Options specifying how the file is opened
 308      *
 309      * @return  A new file channel
 310      *