code: private void handleFile(final String filePath, final AsyncFile file, final InputGroup group) {
      final AtomicLong position = new AtomicLong();
      final AtomicBoolean complete = new AtomicBoolean();
      final AtomicInteger handlerCount = new AtomicInteger();
      group.messageHandler(new Handler<Buffer>() {
        @Override
        public synchronized void handle(Buffer buffer) {
          file.write(buffer, position.get(), new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              if (result.failed()) {
                file.close();
                group.messageHandler(null);
                group.endHandler(null);
                try {
                  input.vertx().fileSystem().deleteSync(filePath);
                } catch (Exception e) {
                }
                if (exceptionHandler != null) {
                  exceptionHandler.handle(result.cause());
                }
              }
  
              // Decrement the handler count.
              handlerCount.decrementAndGet();
  
              // We need to handle for cases where the end handler was called
              // before all the data was written to the file.
              if (complete.get() && handlerCount.get() == 0) {
                closeFile(filePath, file);
              }
            }
          });
          // Increment the handler count and current buffer position.
          handlerCount.incrementAndGet();
          position.addAndGet(buffer.length());
        }
      });
      group.endHandler(new Handler<Void>() {
        @Override
        public void handle(Void event) {
          // If there are still handlers processing the data then wait for
          // those handlers to complete by simply setting the complete flag.
          complete.set(true);
          if (handlerCount.get() == 0) {
            closeFile(filePath, file);
          }
        }
      });
    }
docs: Handles a group input file.