File dirout = new File( outfile) ; dirout.mkdirs(); File out = new File(dirout, File.separator +pixCapchaEngine.getClass().getName().substring( pixCapchaEngine.getClass().getPackage().getName().length()+1 )+"Captcha_" + i + ".jpg"); ImageToFile.serialize(captcha.getImageChallenge(), out); System.out.println("File i created " + out.toURL());
outputDir.mkdirs(); String className = pixCaptchaEngine.getClass().getName().substring(pixCaptchaEngine.getClass().getPackage().getName().length() + 1);  System.out.println("Starting on " + className);  long sumImageCreation = 0; long sumFileCreation = 0; int i = 0; try { for (i = 0; i < iterations; i++) { long t = System.currentTimeMillis(); ImageCaptcha captcha = pixCaptchaEngine.getNextImageCaptcha(); sumImageCreation += System.currentTimeMillis() - t; t = System.currentTimeMillis(); File outputFile = new File(outputDir, File.separator + className + "Captcha_" + i + ".jpg"); ImageToFile.serialize(captcha.getImageChallenge(), outputFile); sumFileCreation += System.currentTimeMillis() - t; System.out.print("."); if ( i % 100 == 99 ) { System.out.println(""); } } } finally { if (i < iterations) { System.out.println("exited early! i=" + i); } else { System.out.println("done"); } DecimalFormat df = new DecimalFormat(); System.out.println("Summary for " + className + ":" + " avg image creation = " + df.format(sumImageCreation / iterations) + " milliseconds/image," + " avg file creation = " + df.format(sumFileCreation / iterations) + " milliseconds/file");
    private static void generate(int iterations, ImageCaptchaEngine pixCapchaEngine, String outfile) throws IOException {        int i;        for (i = 0 ; i < iterations; i++)        {            ImageCaptcha captcha = pixCapchaEngine.getNextImageCaptcha();            System.out.println("Captcha " + i + " retrieved");            File dirout = new File(                    outfile) ;            dirout.mkdirs();            File out = new File(dirout, File.separator +pixCapchaEngine.getClass().getName().substring(                            pixCapchaEngine.getClass().getPackage().getName().length()+1                    )+"Captcha_" + i + ".jpg");            ImageToFile.serialize(captcha.getImageChallenge(), out);            System.out.println("File i created " + out.toURL());        }    }