Skip to content

Commit f191b73

Browse files
committed
Use non-static decimal format.
1 parent 4adf223 commit f191b73

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

storage/ctab/src/main/java/org/openscience/cdk/io/MDLV3000Writer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.io.OutputStreamWriter;
5353
import java.io.Writer;
5454
import java.nio.charset.StandardCharsets;
55+
import java.text.DecimalFormat;
5556
import java.text.SimpleDateFormat;
5657
import java.util.ArrayList;
5758
import java.util.Collection;
@@ -775,8 +776,10 @@ public void close() throws IOException {
775776
* for Sgroups but all lines are handled.
776777
*/
777778
private static final class V30LineWriter implements Closeable {
778-
public static final String PREFIX = "M V30 ";
779-
public static final int LIMIT = 78; // -\n takes two chars (80 total)
779+
// note: non-static
780+
private final DecimalFormat decimalFmt = new DecimalFormat("#.#####");
781+
public static final String PREFIX = "M V30 ";
782+
public static final int LIMIT = 78; // -\n takes two chars (80 total)
780783

781784
// the base writer instance
782785
private final Writer writer;
@@ -854,7 +857,7 @@ private void writePrefixIfNeeded() throws IOException {
854857
* @throws IOException low-level IO error
855858
*/
856859
V30LineWriter write(double num) throws IOException {
857-
return write(String.format(Locale.ROOT, "%.5f", num));
860+
return write(decimalFmt.format(num));
858861
}
859862

860863
/**

0 commit comments

Comments
 (0)