Using the API for generating the name of a molecule:
Molecule m = ...; String name = m.toFormat("name"); String traditionalName = m.toFormat("name:t");
See user's documentation of s2n here.