Hi Lochana,

You need to close the buffer before getting the output.

J

public static String toSDfileString(List<IAtomContainer> ms) throws IOException, CDKException {  
  StringWriter sw  = new StringWriter();
  SDFWriter    sdw = new SDFWriter(sw);
  for (IAtomContainer m : ms){
    sdw.write(ia);
  }
  sdw.close();
  // String sdfString = sw.toString(); // needs to be after close
  return sw.toString();
}