code: public static void main(final String[] args) {
  		int min, max;
  		min = 0;
  		max = Integer.MAX_VALUE;
  		//
  		BigInteger x = BigInteger.valueOf(min);
  		int i = min;
  		final StringBuilder sb = new StringBuilder(64);
  		while (i < max) {
  			x = x.nextProbablePrime();
  			i = x.intValue();
  			sb.append(i).append(',');
  			if (sb.length() > 64) {
  				System.out.println(sb.toString());
  				sb.setLength(0);
  			}
  		}
  		if (sb.length() > 0) {
  			System.out.println(sb.toString());
  			sb.setLength(0);
  		}
  	}
docs: Prime Generator