code: public static DataSet subset(DataSet data, int startIndex, int count) {
      if (data == null) {
        throw new InvalidOperationException("Null data set");
      }
      if (startIndex < 0 || count < 0 || startIndex + count > data.size()) {
        throw new InvalidOperationException("Invalid range.");
      }
      DataSet sub = new DataSet(data.getSource());
      int endIndex = startIndex + count;
      for (int i = startIndex; i < endIndex; i++) {
        sub.rows.add(data.rows.get(i));
      }
      return sub;
    }
docs: Create a subset of the rows of given data set.
  @param data Source data set.
  @param startIndex Start index (from 0 to <code>data.size()-1</code>).
  @param count Number of rows.
  @return A new data set containing
  the rows in the specified range.
  @throws InvalidOperationException if the given data
  set is null or if the specified column range is invalid.