Java 8 AsynchronousFileChannel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AsynchronousFileChannel class.

This code example shows how to use the following methods:lock
    delegate.lock(position, size, shared, attachment, handler);
  } 
 
  @Override 
  public Future<FileLock> lock(long position, long size, boolean shared) {
    return delegate.lock(position, size, shared);
  } 
 
  @Override 
  public FileLock tryLock(long position, long size, boolean shared) throws IOException {
    return delegate.tryLock(position, size, shared);
  } 
 
  @Override 
  public <A> void read(ByteBuffer dst, long position, A attachment, CompletionHandler<Integer,? super A> handler) {
    delegate.read(dst, position, attachment, handler);
  } 
 
  @Override 
  public Future<Integer> read(ByteBuffer dst, long position) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close
    } 
 
    @Override 
    @Suspendable 
    public void close() throws IOException {
        ac.close();
        FiberAsyncIO.runBlockingIO(fiberFileThreadPool, new CheckedCallable<Void, IOException>() {
            @Override 
            public Void call() throws IOException {
                ac.close();
                return null; 
            } 
        }); 
    } 
 
    @Override 
    public long position() throws IOException {
        return position;
    } 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:lock
      assertEquals(10, resultHolder.get());
    } 
  } 
 
  private static void checkAsyncLock(AsynchronousFileChannel channel) throws Throwable {
    assertNotNull(channel.lock().get());
    assertNotNull(channel.lock(0, 10, true).get());
 
    final AtomicReference<FileLock> lockHolder = new AtomicReference<>();
    final AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
    final CountDownLatch completionLatch = new CountDownLatch(1);
    channel.lock(0, 10, true, null, new CompletionHandler<FileLock, Object>() {
      @Override 
      public void completed(FileLock result, Object attachment) { 
        lockHolder.set(result); 
        completionLatch.countDown(); 
      } 
 
      @Override 
      public void failed(Throwable exc, Object attachment) { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 AsynchronousFileChannel Methods: