code: public static void clearToFill(ByteBuffer buffer) {
          if (buffer != null) {
              buffer.position(0);
              buffer.limit(buffer.capacity());
          }
      }
docs: Clear the buffer to be empty in fill mode.
  The position is set to 0 and the limit is set to the capacity.
  
  @param buffer The buffer to clear.