Use UTF-8 encoding in PrintWriter

This commit is contained in:
aherbert 2021-06-09 16:25:35 +01:00
parent 1b6a0f9c9e
commit e300d21251
2 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ package org.apache.commons.math4.examples.sofm.chineserings;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.Callable;
import picocli.CommandLine;
@ -80,7 +81,7 @@ public class StandAlone implements Callable<Void> {
ChineseRingsClassifier sofm) {
final NeuronSquareMesh2D.DataVisualization result = sofm.computeQualityIndicators();
try (final PrintWriter out = new PrintWriter(fileName)) {
try (final PrintWriter out = new PrintWriter(fileName, StandardCharsets.UTF_8.name())) {
out.println("# Number of samples: " + result.getNumberOfSamples());
out.println("# Quantization error: " + result.getMeanQuantizationError());
out.println("# Topographic error: " + result.getMeanTopographicError());

View File

@ -19,6 +19,7 @@ package org.apache.commons.math4.examples.sofm.tsp;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.Callable;
import picocli.CommandLine;
@ -145,7 +146,7 @@ public class StandAlone implements Callable<Void> {
private static void printSummary(String fileName,
City[] travel,
double optimalDistance) {
try (final PrintWriter out = new PrintWriter(fileName)) {
try (final PrintWriter out = new PrintWriter(fileName, StandardCharsets.UTF_8.name())) {
out.println("# Number of unique cities: " + City.unique(travel).size());
out.println("# Travel distance: " + computeDistance(travel));
out.println("# Optimal travel distance: " + optimalDistance);