コード例 #1
0
ファイル: GA.java プロジェクト: JamesEarle/GPP
  public static GA GAWithCheckpoint(String checkpoint) throws Exception {
    File checkpointFile = new File(checkpoint);
    FileInputStream zin = new FileInputStream(checkpointFile);
    GZIPInputStream in = new GZIPInputStream(zin);
    ObjectInputStream oin = new ObjectInputStream(in);

    Checkpoint ckpt = (Checkpoint) oin.readObject();
    GA ga = ckpt.ga;
    ga._checkpoint = ckpt;
    ckpt.checkpointNumber++; // because it gets increased only after ckpt is
    // written

    oin.close();

    System.out.println(ckpt.report.toString());

    // Do we want to append to the file if it exists? Or just overwrite it?
    // Heu! Quae enim quaestio animas virorum vero pertemptit.
    // Wowzers! This is, indeed, a question that truly tests mens' souls.

    if (ga._outputfile != null) ga._outputStream = new FileOutputStream(new File(ga._outputfile));
    else ga._outputStream = System.out;

    return ga;
  }