From 4f74122653c1e23b756f62597cea89c4bf7f8772 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 4 Aug 2022 10:21:19 -0400 Subject: [PATCH] Slightly more efficient conversion to string --- .../java/org/openmrs/module/fhir2/api/util/GeneralUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/util/GeneralUtils.java b/api/src/main/java/org/openmrs/module/fhir2/api/util/GeneralUtils.java index abfbd55c5..5669418f4 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/util/GeneralUtils.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/util/GeneralUtils.java @@ -14,6 +14,7 @@ import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import lombok.extern.slf4j.Slf4j; @@ -30,7 +31,7 @@ public static String inputStreamToString(final InputStream is, final Charset cha while ((length = is.read(buffer)) != -1) { outputStream.write(buffer, 0, length); } - return new String(charset.decode(ByteBuffer.wrap(outputStream.toByteArray())).array()); + return outputStream.toString(charset.name()); } public static String resourceToString(final String resource, final Charset charset, final ClassLoader cl)