code: @Override
      public RandomElementReader duplicate() {
          if (closed) {
              throw new IllegalStateException("Reader is closed.");
          }
  
          return new RandomElementReader() {
  
              private boolean closed = false;
              private int nextElement = 0;
  
              @Override
              public Element readElement(int index) throws IOException {
                  if (closed) {
                      throw new IllegalStateException("Reader closed");
                  }
                  return BufferedElementReader.this.readElement(index);
              }
  
              @Override
              public ElementType getElementType() {
                  return BufferedElementReader.this.getElementType();
              }
  
              @Override
              public int getCount() {
                  return BufferedElementReader.this.getCount();
              }
  
              @Override
              public Element readElement() throws IOException {
  
                  if (nextElement >= getCount()) {
                      return null;
                  }
                  if (closed) {
                      throw new IllegalStateException("Reader closed");
                  }
                  return BufferedElementReader.this.readElement(nextElement++);
              }
  
              @Override
              public void close() throws IOException {
                  closed = true;
              }
  
              @Override
              public RandomElementReader duplicate() {
                  return BufferedElementReader.this.duplicate();
              }
  
              @Override
              public boolean isClosed() {
                  return closed;
              }
          };
      }
docs: Creates a duplicate of this stream.
  <p>Closing the duplicate will not close this stream.</p>
  <p>Both stream have a independent current position.</p>
  @return Stream that can be closed without affecting this stream.