code: @Override
      public int read(final ByteBuffer destination) throws IOException {
  
          // Precondition checks
          this.checkClosed();
          if (destination == null) {
              throw new IllegalArgumentException("Destination buffer must be supplied");
          }
  
          // Init
          final int spaceInBuffer = destination.remaining();
          final int numBytesRemainingInContent, numBytesToRead;
  
          // Sync up before getting at shared mutable state
          synchronized (this) {
              numBytesRemainingInContent = this.contents.length - this.position;
  
              // Set position was greater than the size? Just return.
              if (numBytesRemainingInContent <= 0) {
                  return -1;
              }
  
              // We'll read in either the number of bytes remaining in content or the amount of space in the buffer,
              // whichever is smaller
              numBytesToRead = numBytesRemainingInContent >= spaceInBuffer ? spaceInBuffer : numBytesRemainingInContent;
              // Copy a sub-array of the bytes we'll put into the buffer
              destination.put(this.contents, this.position, numBytesToRead);
  
              // Set the new position
              this.position += numBytesToRead;
          }
  
          // Return the number of bytes read
          return numBytesToRead;
      }
docs: {@inheritDoc}
  
  @see java.nio.channels.SeekableByteChannel#read(java.nio.ByteBuffer)