code: public static void enumeratekeys(Descriptor desc, PrintStream outs, CFMetaData metadata)
      throws IOException
      {
          KeyIterator iter = new KeyIterator(desc);
          try
          {
              DecoratedKey lastKey = null;
              while (iter.hasNext())
              {
                  DecoratedKey key = iter.next();
  
                  // validate order of the keys in the sstable
                  if (lastKey != null && lastKey.compareTo(key) > 0)
                      throw new IOException("Key out of order! " + lastKey + " > " + key);
                  lastKey = key;
  
                  outs.println(metadata.getKeyValidator().getString(key.getKey()));
                  checkStream(outs); // flushes
              }
          }
          finally
          {
              iter.close();
          }
      }
docs: Enumerate row keys from an SSTableReader and write the result to a PrintStream.
  
  @param desc the descriptor of the file to export the rows from
  @param outs PrintStream to write the output to
  @param metadata Metadata to print keys in a proper format
  @throws IOException on failure to read/write input/output