Files a bug and provided a patch for master here: https://sourceforge.net/p/cdk/bugs/1262/

CMLWriter won't close the underlying stream if a writer was provided.This is because CMLWriter maintains an OutputStream and a Writer. The attached patch removes the Writer and adds conversion from Writer -> OutputStream. This isn't always desirable due to encodings so a warning message was added. A null check was also added to 'close()' method.The CMLReader (which uses just an InputStream) throws an IllegalArgumentException if you try to use a Reader - this could also be done for CMLWriter but I think adding the conversion is more user friendly.
I'm not 100% on converting a Writer to an OutputStream but I think in this instance it is okay as Jumbo handles the encodings - still needs a second pair of eyes.

J

On 16 Oct 2012, at 09:33, John May <john.wilkinsonmay@gmail.com> wrote:

cmlwriter.close(); "should" also close the underlying stream of output.close().
However the CML writer is a bit strange an maintains both Writer and OutputStream and only the OutputStream gets closed - this is a bug.

You should normally use Reader/Writer for text but the following works:

OutputStream output = new FileOutputStream("molecule.cml");
CMLWriter cmlwriter = new CMLWriter(output);
cmlwriter.write(molecule);
cmlwriter.close();

J

On 16 Oct 2012, at 03:13, Francois Berenger <berenger@riken.jp> wrote:

In the javadoc of org.openscience.cdk.io.CMLWriter:

---
Output to a file called "molecule.cml" can done with:

  FileWriter output = new FileWriter("molecule.cml");
  CMLWriter cmlwriter = new CMLWriter(output);
  cmlwriter.write(molecule);
  cmlwriter.close();
---

you need to add
output.close();
as the last line so that the file is really written out to disk.

Regards,
F.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Cdk-devel mailing list
Cdk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-devel