/// <summary>Write output to files.</summary>
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Cleanup(Reducer.Context context)
            {
                Configuration conf = context.GetConfiguration();
                Path          dir  = new Path(conf.Get(WorkingDirProperty));
                FileSystem    fs   = dir.GetFileSystem(conf);

                {
                    // write hex output
                    Path         hexfile = new Path(conf.Get(HexFileProperty));
                    OutputStream @out    = new BufferedOutputStream(fs.Create(hexfile));
                    try
                    {
                        foreach (byte b in hex)
                        {
                            @out.Write(b);
                        }
                    }
                    finally
                    {
                        @out.Close();
                    }
                }
                // If the starting digit is 1,
                // the hex value can be converted to decimal value.
                if (conf.GetInt(DigitStartProperty, 1) == 1)
                {
                    Path outfile = new Path(dir, "pi.txt");
                    Log.Info("Writing text output to " + outfile);
                    OutputStream outputstream = fs.Create(outfile);
                    try
                    {
                        PrintWriter @out = new PrintWriter(new OutputStreamWriter(outputstream, Charsets.
                                                                                  Utf8), true);
                        // write hex text
                        Print(@out, hex.GetEnumerator(), "Pi = 0x3.", "%02X", 5, 5);
                        @out.WriteLine("Total number of hexadecimal digits is " + 2 * hex.Count + ".");
                        // write decimal text
                        BaileyBorweinPlouffe.Fraction dec = new BaileyBorweinPlouffe.Fraction(hex);
                        int decDigits = 2 * hex.Count;
                        // TODO: this is conservative.
                        Print(@out, new _IEnumerator_168(decDigits, dec), "Pi = 3.", "%d", 10, 5);
                        @out.WriteLine("Total number of decimal digits is " + decDigits + ".");
                    }
                    finally
                    {
                        outputstream.Close();
                    }
                }
            }
 public _IEnumerator_168(int decDigits, BaileyBorweinPlouffe.Fraction dec)
 {
     this.decDigits = decDigits;
     this.dec       = dec;
     this.i         = 0;
 }