public Piece getPiece(int index) {
    if (this.pieces == null) {
      throw new IllegalStateException("Torrent not initialized yet.");
    }

    if (index >= this.pieces.length) {
      throw new IllegalArgumentException("Invalid piece index!");
    }

    return this.pieces[index];
  }
public Piece getPiece ( int index ) { if ( this . pieces == null ) { throw new IllegalStateException ( "Torrent not initialized yet." ) ; } if ( index >= this . pieces . length ) { throw new IllegalArgumentException ( "Invalid piece index!" ) ; } return this . pieces [ index ] ; }
Retrieve a piece object by index.

@param index The index of the piece in this torrent.