GaussianInputWriter extends DefaultChemObjectWriter { @Override public void write(IChemObject object) throws CDKException { if (object instanceof IAtomContainer) { try { writeMolecule((IAtomContainer) object); } catch (Exception ex) { throw new CDKException("Error while writing Gaussian input file: " + ex.getMessage(), ex); } } else { throw new CDKException("GaussianInputWriter only supports output of Molecule classes."); } } GaussianInputWriter(Writer out);  GaussianInputWriter(OutputStream output);  GaussianInputWriter(); @Override IResourceFormat getFormat(); @Override void setWriter(Writer out); @Override void setWriter(OutputStream output); @Override void close(); @Override boolean accepts(Class<? extends IChemObject> classObject); @Override void write(IChemObject object); void writeMolecule(IAtomContainer mol);  }
@Test public void testWrite() throws Exception { IAtomContainer molecule = TestMoleculeFactory.makeAlphaPinene(); StringWriter writer = new StringWriter(); GaussianInputWriter gaussianWriter = new GaussianInputWriter(writer); gaussianWriter.write(molecule); gaussianWriter.close(); String output = writer.toString(); Assert.assertNotSame(0, output.length()); }