From ed613e767ad47b589a2aa98be7c10765d8b0af2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C7fantasy7=E2=80=9D?= Date: Sat, 18 Nov 2023 21:55:10 +0300 Subject: [PATCH] Skip buffer in StreamUtils#copy(String) (cherry picked from commit 54f87f1ff796eff3b54d61ed4992f86ef93b6483) --- .../main/java/org/springframework/util/StreamUtils.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/StreamUtils.java b/spring-core/src/main/java/org/springframework/util/StreamUtils.java index 95368a137d93..99d09eefe1a6 100644 --- a/spring-core/src/main/java/org/springframework/util/StreamUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StreamUtils.java @@ -23,8 +23,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; import java.nio.charset.Charset; import org.springframework.lang.Nullable; @@ -133,9 +131,8 @@ public static void copy(String in, Charset charset, OutputStream out) throws IOE Assert.notNull(charset, "No Charset specified"); Assert.notNull(out, "No OutputStream specified"); - Writer writer = new OutputStreamWriter(out, charset); - writer.write(in); - writer.flush(); + out.write(in.getBytes(charset)); + out.flush(); } /**