end of line characters

User 870ab5b546

26-07-2007 17:54:27

We notice that MRV strings obtained from Marvin contain both \r and \n characters at the end of each line.





Three questions:





(1) Is this true also of strings in other formats such as MOL?





(2) Is there any circumstance under which Marvin would *not* put both \r and \n characters at the end of every line?





(3) Do API methods such as Molecule.toFormat("mrv") also put \r and \n characters at the end of every line?

User f359e526a1

26-07-2007 19:08:08

If you are modifying a file, there is a method trying to determine the linefeed from the existing file. If you are creating a new one, the EOL is asked like


Code:
String eol = System.getProperty("line.separator");



So if you have \r\n in the file already, it will be saved using \r\n as EOL. This is done in the saving section, so





1) yes


2) yes, if there are \n -s in the file that you are modifying or as reported by the System.getProperty() call


3) no.

User c0e481a82c

23-10-2007 15:38:36

With regards to this though, what if you need the CTAB with the platform end of line character? I'm creating a SD file from a JTable in my application, and if I don't get the platform end of line for the CTAB of the molecules in the table, my file ends up looking rather odd, and not being recognised by some other applications as a valid SD file (the structure has just \n whilst the rest of the file has \r\n). My table can get data from a number of sources, one of which is simply from a column of SMILES strings (see the example at the end).





Is there any way to make the Molecule toFormat("mol") method use the default platform end of line? I can work around this, but it's just a little odd that's all. I'm using the JChem 3.2.1 JAR file. Thanks for your help in advance.





Regards,





Phil.





PS. For a simple example of what I'm trying to say, use the code below (and run it on a Windows machine):





Code:



    try {


      Molecule m = MolImporter.importMol("c1ccccc1");


      String sCTAB = m.toFormat("mol");


     


      if (sCTAB.contains(System.getProperty("line.separator"))) {


        System.out.println("Platform line feed!!");


      }


      else {


        System.out.println("Non-platform line feed!!");


      }


    }


    catch (MolFormatException e) {


      e.printStackTrace();


    }


ChemAxon 7c2d26e5cf

24-10-2007 14:38:31

Please use the chemaxon.formats.MolConverter API. You can specify in the MolConverter constructor to use system dependent/independent line separator.


Or you can use directly the chemaxon.formats.MolExporter to specify which line separator you prefer.