@Override public SeekableByteChannel newByteChannel(final Path path, final Set<? extends OpenOption> options, final FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { return Files.newByteChannel(path, options, attrs); }
@Override public SeekableByteChannel newByteChannel(final Path path, final OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { return Files.newByteChannel(path, options); }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws FileAlreadyExistsException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newByteChannel(java.nio.file.Path, java.nio.file.OpenOption...)">Original JavaDoc</a> */ public static SeekableByteChannel newByteChannel(final Path path, final OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); final Set<OpenOption> set = new HashSet<OpenOption>(options.length); addAll(set, options); return newByteChannel(path, set); }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws FileAlreadyExistsException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newByteChannel(java.nio.file.Path, java.nio.file.OpenOption...)">Original JavaDoc</a> */ public static SeekableByteChannel newByteChannel(final Path path, final OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); final Set<OpenOption> set = new HashSet<OpenOption>(options.length); addAll(set, options); return newByteChannel(path, set); }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws FileAlreadyExistsException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newByteChannel(java.nio.file.Path, java.nio.file.OpenOption...)">Original JavaDoc</a> */ public static SeekableByteChannel newByteChannel(final Path path, final OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); final Set<OpenOption> set = new HashSet<OpenOption>(options.length); addAll(set, options); return newByteChannel(path, set); }
@Test public void newByteChannelNull() { assertThatThrownBy(() -> Files.newByteChannel(null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Parameter named 'path' should be not null!"); }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws FileAlreadyExistsException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createFile(java.nio.file.Path, java.nio.file.attribute.FileAttribute...)">Original JavaDoc</a> */ public static Path createFile(final Path path, final FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); try { newByteChannel(path, CREATE_NEW_FILE_OPTIONS, attrs).close(); } catch (java.io.IOException e) { throw new IOException(e); } return path; }
@Test public void newByteChannelFileAlreadyExists() { assertThatThrownBy(() -> Files.newByteChannel(Files.createTempFile("foo", "bar"))) .isInstanceOf(FileAlreadyExistsException.class); }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws FileAlreadyExistsException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createFile(java.nio.file.Path, java.nio.file.attribute.FileAttribute...)">Original JavaDoc</a> */ public static Path createFile(final Path path, final FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); try { newByteChannel(path, CREATE_NEW_FILE_OPTIONS, attrs).close(); } catch (java.io.IOException e) { throw new IOException(e); } return path; }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws FileAlreadyExistsException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createFile(java.nio.file.Path, java.nio.file.attribute.FileAttribute...)">Original JavaDoc</a> */ public static Path createFile(final Path path, final FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); try { newByteChannel(path, CREATE_NEW_FILE_OPTIONS, attrs).close(); } catch (java.io.IOException e) { throw new IOException(e); } return path; }
@Test public void newByteChannel() throws IOException { try (final SeekableByteChannel sbc = Files.newByteChannel(newTempDir().resolve("file.temp.txt"), new HashSet<>())) { assertThat(sbc).isNotNull(); } try (final SeekableByteChannel sbc2 = Files.newByteChannel(newTempDir().resolve("file.temp2.txt"))) { assertThat(sbc2).isNotNull(); } }
@Override public SeekableByteChannel newByteChannel(final Path path, final Set<? extends OpenOption> options, final FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("path", path); final Properties properties = new Properties(); if (exists(dot(path))) { properties.load(newInputStream(dot(path))); } final FileAttribute<?>[] allAttrs = consolidate(properties, attrs); final SeekableByteChannel result = Files.newByteChannel(path, buildOptions(options), allAttrs); if (isFileScheme(path)) { buildDotFile(path, newOutputStream(dot(path)), allAttrs); } return result; }