return new XnioFileChannel(path.getFileSystem().provider().newFileChannel(path, openOptions)); } catch (NoSuchFileException e) { throw new FileNotFoundException(e.getMessage());
@Override public void startup() { if (null!=inputPathString && inputPathString.length()>0) { this.fileSystem = FileSystems.getDefault(); this.provider = fileSystem.provider(); this.readOptions = new HashSet<OpenOption>(); this.readOptions.add(StandardOpenOption.READ); this.readOptions.add(StandardOpenOption.SYNC); try { fileChannel = provider.newFileChannel(fileSystem.getPath(inputPathString), readOptions); //logger.info("\nfile: {} size: {} ", inputPathString, fileChannel.size()); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public FileChannel newFileChannel(final Path path, final Set<? extends OpenOption> options, final FileAttribute<?>... attrs) throws IOException { if (isWriteAccess(options)) throw new ReadOnlyFileSystemException(); return delegate.newFileChannel(path, options, attrs); }
while (--i>=0) { this.path[i] = this.fileSystem.getPath(this.paths[i]); this.fileChannel[i] = this.provider.newFileChannel(path[i], this.options); this.fileChannel[i].position(this.fileChannel[i].size());
@Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { Path r = unroot(path); FileSystemProvider p = provider(r); return p.newFileChannel(r, options, attrs); }
@Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { Path r = unroot(path); FileSystemProvider p = provider(r); return p.newFileChannel(r, options, attrs); }
@Override public FileChannel newFileChannel(final Path path, final Set<? extends OpenOption> options, final FileAttribute<?>[] attrs) throws IOException { return wrapped().newFileChannel(unwrap(path), options, attrs); }
@Override public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { final Path resolved = resolveRelative(path); try { return delegate.newFileChannel(resolved, options, attrs); } catch (UnsupportedOperationException uoe) { return delegate.newByteChannel(resolved, options, attrs); } }
@Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { Path r = unroot(path); FileSystemProvider p = provider(r); return p.newFileChannel(r, options, attrs); }
@Test @Category( FileChannelT.class ) public void testNewFileChannelOtherProvider() throws IOException { assertThatThrownBy( () -> FS.provider().newFileChannel( otherProviderAbsA(), Collections.<OpenOption> emptySet() ) ).isInstanceOf( ProviderMismatchException.class ); }
this.absoluteFileNames[selectedFile] = generateFileName(extension); fileChannel = provider.newFileChannel( fileSystem.getPath(this.absoluteFileNames[selectedFile]), writeOptions);
@Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { final BundleFileSystem fs = (BundleFileSystem) path.getFileSystem(); FileChannel fc = origProvider(path).newFileChannel(fs.unwrap(path), options, attrs); return new BundleFileChannel(fc, path, options, attrs); }
static <I extends DataItem, O extends DataIoTask<I>> FileChannel openSrcFile(final O ioTask) { String srcPath = ioTask.getSrcPath(); if(srcPath == null || srcPath.isEmpty()) { return null; } if(srcPath.startsWith("/")) { srcPath = srcPath.substring(1); } final String fileItemName = ioTask.getItem().getName(); final Path srcFilePath = srcPath.isEmpty() || fileItemName.startsWith(srcPath) ? FS.getPath(fileItemName) : FS.getPath(srcPath, fileItemName); try { return FS_PROVIDER.newFileChannel(srcFilePath, READ_OPEN_OPT); } catch(final IOException e) { LogUtil.exception(Level.WARN, e, "Failed to open the source channel for the path @ \"{}\"", srcFilePath); ioTask.setStatus(IoTask.Status.FAIL_IO); return null; } }
.of(StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW); origProvider(path).newFileChannel(zipPath, opts, attrs).close();
@Test( expected = ClosedFileSystemException.class ) @Category({ Closable.class, FileChannelT.class }) public void testClosedFSNewFileChannel() throws IOException { getClosedFSProvider().newFileChannel( getClosedFileA(), Collections.<OpenOption> emptySet() ); }
private void findAgainFileChannel(int pathId) { /////////////// //we lost our file channel and need to request a new one. ////////////// try { assert( data.getPaths().length > 0); assert( data.getPaths()[pathId].toFile().isFile() ); assert( data.getPaths()[pathId].toFile().exists() ); //logger.info("looking for {}",data.getPaths()[pathId]); activeFileChannel = data.fileSystem.provider().newFileChannel(data.getPaths()[pathId], data.getReadOptions()); data.getFcId()[pathId] = channelHolder.add(activeFileChannel); data.getFileSizes()[pathId] = activeFileChannel.size(); } catch (IOException e) { throw new RuntimeException(e); } }
FileChannel activeFileChannel = data.fileSystem.provider().newFileChannel(path, data.getReadOptions());
@Test public void fileChannelCreateNew() throws Exception { Path test = fs.getPath("test.txt"); EnumSet<StandardOpenOption> options = EnumSet.<StandardOpenOption> of( StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE); fs.provider().newFileChannel(test, options); }
return new XnioFileChannel(path.getFileSystem().provider().newFileChannel(path, openOptions)); } catch (NoSuchFileException e) { throw new FileNotFoundException(e.getMessage());
return FS_PROVIDER.newFileChannel(itemPath, CREATE_OPEN_OPT); } else { return FS_PROVIDER.newFileChannel(itemPath, WRITE_OPEN_OPT);