Lines Matching refs:file

12  * version 2 for more details (a copy is included in the LICENSE file that
26 * @summary Unit test for java.nio.file.Files.newByteChannel
31 import java.nio.file.*;
32 import static java.nio.file.StandardOpenOption.*;
33 import static com.sun.nio.file.ExtendedOpenOption.*;
34 import java.nio.file.attribute.FileAttribute;
73 Path file = dir.resolve("foo");
77 // create file (no existing file)
78 Files.newByteChannel(file, CREATE, WRITE).close();
79 if (Files.notExists(file))
82 // create file (existing file)
83 Files.newByteChannel(file, CREATE, WRITE).close();
85 // create file where existing file is a sym link
87 Path link = Files.createSymbolicLink(dir.resolve("link"), file);
89 // file already exists
92 // file does not exist
93 Files.delete(file);
95 if (Files.notExists(file))
104 TestUtil.deleteUnchecked(file);
109 // create file
110 Files.newByteChannel(file, CREATE_NEW, WRITE).close();
111 if (Files.notExists(file))
117 Files.newByteChannel(file, CREATE_NEW, WRITE);
131 Files.newByteChannel(file, CREATE_NEW, WRITE);
143 TestUtil.deleteUnchecked(file);
148 try (SeekableByteChannel sbc = Files.newByteChannel(file, CREATE_NEW, WRITE, SPARSE)) {
157 TestUtil.deleteUnchecked(file);
163 Path file = dir.resolve("foo");
165 // "hello there" should be written to file
166 try (SeekableByteChannel sbc = Files.newByteChannel(file, CREATE_NEW, WRITE, APPEND)) {
172 // check file
173 try (Scanner s = new Scanner(file)) {
176 throw new RuntimeException("Unexpected file contents");
180 try (SeekableByteChannel sbc = Files.newByteChannel(file, APPEND)) {
186 TestUtil.deleteUnchecked(file);
192 Path file = dir.resolve("foo");
194 try (SeekableByteChannel sbc = Files.newByteChannel(file, CREATE_NEW, WRITE)) {
200 try (SeekableByteChannel sbc = Files.newByteChannel(file, WRITE, TRUNCATE_EXISTING)) {
203 try (Scanner s = new Scanner(file)) {
206 throw new RuntimeException("Unexpected file contents");
210 // check file is of size 0L
211 try (SeekableByteChannel sbc = Files.newByteChannel(file, WRITE, CREATE, TRUNCATE_EXISTING)) {
219 TestUtil.deleteUnchecked(file);
228 Path file = Files.createFile(dir.resolve("foo"));
232 Files.createSymbolicLink(link, file);
245 TestUtil.deleteUnchecked(file);
251 Path file = dir.resolve("foo");
253 try (SeekableByteChannel sbc = Files.newByteChannel(file, CREATE_NEW, READ, WRITE)) {
277 TestUtil.deleteUnchecked(file);
284 Path file = Files.createFile(dir.resolve("foo"));
287 try (SeekableByteChannel ch = Files.newByteChannel(file, READ, NOSHARE_READ,
291 Files.newByteChannel(file, READ);
295 Files.newByteChannel(file, WRITE);
299 Files.delete(file);
305 try (SeekableByteChannel ch = Files.newByteChannel(file, READ, NOSHARE_WRITE, NOSHARE_DELETE)) {
306 Files.newByteChannel(file, READ).close();
308 Files.newByteChannel(file, WRITE);
312 Files.delete(file);
318 try (SeekableByteChannel ch = Files.newByteChannel(file, READ, NOSHARE_READ, NOSHARE_DELETE)) {
320 Files.newByteChannel(file, READ);
323 Files.newByteChannel(file, WRITE).close();
325 Files.delete(file);
331 try (SeekableByteChannel ch = Files.newByteChannel(file, READ, NOSHARE_READ, NOSHARE_WRITE)) {
333 Files.newByteChannel(file, READ);
337 Files.newByteChannel(file, WRITE);
340 Files.delete(file);
344 TestUtil.deleteUnchecked(file);
350 Path file = dir.resolve("bad");
353 Files.newByteChannel(file, READ, APPEND);
358 Files.newByteChannel(file, WRITE, APPEND, TRUNCATE_EXISTING);
365 Path file = dir.resolve("bad");
369 Files.newByteChannel(file, badOption);
373 Files.newByteChannel(file, READ, WRITE, badOption);
380 Path file = dir.resolve("foo");
389 Files.newByteChannel(file, (OpenOption[])null);
395 Files.newByteChannel(file, opts);
400 Files.newByteChannel(file, (Set<OpenOption>)null);
408 Files.newByteChannel(file, opts);
414 Files.newByteChannel(file, opts, (FileAttribute[])null);
421 Files.newByteChannel(file, opts, attrs);