I would like some feedback on a Java program which implements the Sieve of Eratosthenes to find prime numbers. Some of the 'features' I've included in the program include:

It uses a `BitSet` for identifying primes. What really gets checked is whether the index of any bit is prime. This eliminates the need to store the primes as actual numbers.

The program runs fairly quickly. It can identify over 105 million primes in about 44 seconds on my iMac.

I implemented a timer because I was tired of watching the clock.

I know I probably haven't done everything 'by the book' with this, so let me know where you think I need to do some cleanup.

```
//package Eratosthenes5;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.BitSet;

public class Eratosthenes5 {

    // This uses a BitSet instead of a boolean array to see
    // if this saves any memory. It enables me to test approx.
    // 8x as many numbers. 109905151 is no longer my max.
    // The highest number I've reached, so far, is around 879,400,000.
    //
    // After giving more memory to the app, I can check for primes up
    // to around 2 billion. I've not determined the upper limit, but
    // I suspect it is the java max integer size. It finds almost
    // 100 million primes in under a minute.
    // 2^31 = 2,147,483,648

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        int maxSize = 1;
        int maxNumber;
        int maxSearch;
        int primeCount;
        int maxPrime;
        String name;
        name = getTheMaxNumber();
        while (name.compareTo("1") != 0) {
            long startTime = System.currentTimeMillis();
            maxSize = Integer.parseInt(name);
            maxNumber = maxSize + 1;
            maxSearch = (int) java.lang.Math.sqrt(maxNumber);
            primeCount = 1; // Start the count at 1 because 2 is prime and we'll
                            // start at 3
            maxPrime = -1;
            // use a BitSet array to maximize how many primes can be found
            BitSet numbList = new BitSet(maxNumber);

            numbList.set(0, maxNumber - 1, true); // set all bits to true

            numbList.clear(0);
            numbList.clear(1);

            // clear the even numbers (except 2, it's prime)
            for (long k = 4; k <= maxSize; k += 2) {
                numbList.clear((int) k);
            }

            // sieve out the non-primes
            for (int k = 3; k < maxSearch; k += 2) {
                if (numbList.get(k)) {
                    sieveTheRest(k, numbList, maxSize);
                }
            }

            // Count the primes
            for (int k = 3; k <= maxSize; k += 2) {
                if (numbList.get(k)) {
                    maxPrime = k;
                    primeCount += 1;
                    if (primeCount % 1000000 == 0) {
                        System.out.format("the "
                                + ((primeCount / 1000000 < 100) ? " " : "")
                                + ((primeCount / 1000000 < 10) ? " " : "")
                                + primeCount / 1000000
                                + " millionth prime is: %,11d%n", maxPrime);
                    }
                }
            }

            // we're done
            System.out.format("\nMy integer from beg: %,11d%n", Integer
                    .parseInt(name));
            System.out.format("array size         : %,11d%n", maxNumber);
            System.out.format("prime count        : %,11d%n", numbList
                    .cardinality());
            System.out.format("largest prime found: %,11d%n", maxPrime);
            System.out.format("max factor         : %,11d%n \n", maxSearch);

            long stopTime = System.currentTimeMillis();
            System.out.println("That took " + (stopTime - startTime) / 1000.0
                    + " seconds");

            name = getTheMaxNumber();
        }// end of while
        System.out.println("\nEnd of program");

    }// End of method Main
    /**
     * 
     * @return Passes back a string holding the maximum number to check
     */
    static String getTheMaxNumber() {
        BufferedReader dataIn = new BufferedReader(new InputStreamReader(
                System.in));
        String bigNumber = "";
        System.out.print("Please enter an integer value (1 to quit): ");
        try {
            bigNumber = dataIn.readLine();
        } catch (IOException e) {
            System.out.println("Error!");
        }
        return bigNumber;
    }
    /**
     * @param myPrime
     *            The latest prime to be found.
     * @param theBitSet
     *            The BitSet holding the prime flags
     * @param maxSize
     *            The largest index in the BitSet
     */
    static void sieveTheRest(int myPrime, BitSet theBitSet, int maxSize) {
        for (long k = myPrime * myPrime; k <= maxSize; k += 2 * myPrime) {
            theBitSet.clear((int) k);
        }
    }

}// End of Class eratosthenes5

```