diff --git a/src/main/java/org/orekit/rugged/errors/RuggedMessages.java b/src/main/java/org/orekit/rugged/errors/RuggedMessages.java index 740e92f3a91f47732ac058b68e6f716e2f9ba2ab..98accfea1a8d160274ffda1df62ead21d62997bc 100644 --- a/src/main/java/org/orekit/rugged/errors/RuggedMessages.java +++ b/src/main/java/org/orekit/rugged/errors/RuggedMessages.java @@ -21,6 +21,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.Locale; import java.util.MissingResourceException; import java.util.PropertyResourceBundle; @@ -164,11 +165,9 @@ public enum RuggedMessages implements Localizable { stream = loader.getResourceAsStream(resourceName); } if (stream != null) { - try { + try (InputStreamReader inputStreamReader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { // Only this line is changed to make it to read properties files as UTF-8. - bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); - } finally { - stream.close(); + bundle = new PropertyResourceBundle(inputStreamReader); } } return bundle;