outW = null; resetWriter(); setWriteMode(CANCEL);
  public void writeBatch() throws IOException {        if(getInstances() == null)          throw new IOException("No instances to save");      if(getRetrieval() == INCREMENTAL)          throw new IOException("Batch and incremental saving cannot be mixed.");      setRetrieval(BATCH);      setWriteMode(WRITE);      if(retrieveFile() == null || getWriter() == null){          // print out attribute names as first row          for (int i = 0; i < getInstances().numAttributes(); i++) {            System.out.print(getInstances().attribute(i).name());            if (i < getInstances().numAttributes()-1) {                System.out.print(",");            } else {            System.out.println();            }        }        for (int i = 0; i < getInstances().numInstances(); i++) {            System.out.println(getInstances().instance(i));        }        setWriteMode(WAIT);        return;      }      PrintWriter outW = new PrintWriter(getWriter());      // print out attribute names as first row      for (int i = 0; i < getInstances().numAttributes(); i++) {	outW.print(getInstances().attribute(i).name());	if (i < getInstances().numAttributes()-1) {	  outW.print(",");	} else {	  outW.println();	}      }      for (int i = 0; i < getInstances().numInstances(); i++) {	outW.println(getInstances().instance(i));      }      outW.flush();      outW.close();      setWriteMode(WAIT);        }