IIRC the output is internally buffered, you're calling flush but it won't
do anything. Try closing the files to force the flush.
try (MDLV3000Writer mdlw = new MDLV3000Writer(System.out)) {
mdlw.write(mol);
}
You can also manually buffer your output:
StringWriter writer2 = new StringWriter();
BufferedWriter bwriter2 = new BufferedWriter(writer2);
MDLV3000Writer mdl = new MDLV3000Writer(bwriter2);
mdl.write(mol);
bwriter2.flush();
String v3000 = writer2.toString();
Also - SilentChemObjectBuilder! I really want to just remove that
DefaultChemObjectBuilder so much misuse.
John
On 6 February 2017 at 17:43, Tim Dudgeon wrote:
> I'm finding that the MDLV3000Writer class does not seem to output anything.
> In the example below the V2000 output is fine, but the V3000 output is an
> empty String.
>
> Is this a bug?
>
> Thanks
> Tim
>
>
> SmilesParser smilesParser = new
> SmilesParser(DefaultChemObjectBuilder.getInstance());
> IAtomContainer mol = smilesParser.parseSmiles("CCO");
>
> StringWriter writer1 = new StringWriter();
> MDLV2000Writer v2000writer = new MDLV2000Writer(writer1);
> v2000writer.write(mol);
> writer1.flush();
> String v2000 = writer1.toString();
>
> StringWriter writer2 = new StringWriter();
> MDLV3000Writer mdl = new MDLV3000Writer(writer2);
> mdl.write(mol);
> writer2.flush();
> String v3000 = writer2.toString();
>
>
>
>
>
>
>
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Cdk-user mailing list
> Cdk-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user