279 * @throws IllegalArgumentException
280 * If the set contains an invalid combination of options
281 * @throws UnsupportedOperationException
282 * If the {@code file} is associated with a provider that does not
283 * support creating file channels, or an unsupported open option is
284 * specified
285 * @throws IOException
286 * If an I/O error occurs
287 * @throws SecurityException
288 * If a security manager is installed and it denies an
289 * unspecified permission required by the implementation.
290 * In the case of the default provider, the {@link
291 * SecurityManager#checkRead(String)} method is invoked to check
292 * read access if the file is opened for reading. The {@link
293 * SecurityManager#checkWrite(String)} method is invoked to check
294 * write access if the file is opened for writing
295 */
296 public static AsynchronousFileChannel open(Path file, OpenOption... options)
297 throws IOException
298 {
299 Set<OpenOption> set = new HashSet<OpenOption>(options.length);
300 Collections.addAll(set, options);
301 return open(file, set, null, NO_ATTRIBUTES);
302 }
303
304 /**
305 * Returns the current size of this channel's file.
306 *
307 * @return The current size of this channel's file, measured in bytes
308 *
309 * @throws ClosedChannelException
310 * If this channel is closed
311 * @throws IOException
312 * If some other I/O error occurs
313 */
314 public abstract long size() throws IOException;
315
316 /**
317 * Truncates this channel's file to the given size.
318 *
319 * <p> If the given size is less than the file's current size then the file
|
279 * @throws IllegalArgumentException
280 * If the set contains an invalid combination of options
281 * @throws UnsupportedOperationException
282 * If the {@code file} is associated with a provider that does not
283 * support creating file channels, or an unsupported open option is
284 * specified
285 * @throws IOException
286 * If an I/O error occurs
287 * @throws SecurityException
288 * If a security manager is installed and it denies an
289 * unspecified permission required by the implementation.
290 * In the case of the default provider, the {@link
291 * SecurityManager#checkRead(String)} method is invoked to check
292 * read access if the file is opened for reading. The {@link
293 * SecurityManager#checkWrite(String)} method is invoked to check
294 * write access if the file is opened for writing
295 */
296 public static AsynchronousFileChannel open(Path file, OpenOption... options)
297 throws IOException
298 {
299 Set<OpenOption> set = new HashSet<>(options.length);
300 Collections.addAll(set, options);
301 return open(file, set, null, NO_ATTRIBUTES);
302 }
303
304 /**
305 * Returns the current size of this channel's file.
306 *
307 * @return The current size of this channel's file, measured in bytes
308 *
309 * @throws ClosedChannelException
310 * If this channel is closed
311 * @throws IOException
312 * If some other I/O error occurs
313 */
314 public abstract long size() throws IOException;
315
316 /**
317 * Truncates this channel's file to the given size.
318 *
319 * <p> If the given size is less than the file's current size then the file
|