Browse Source

Use Reader.transferTo in FileCopyUtils

Use the transferTo method in FileCopyUtils#copy(Reader, Writer).

Closes gh-36196

Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>
pull/36221/head
Patrick Strawderman 1 week ago committed by Brian Clozel
parent
commit
96fb5d72eb
  1. 8
      spring-core/src/main/java/org/springframework/util/FileCopyUtils.java

8
spring-core/src/main/java/org/springframework/util/FileCopyUtils.java

@ -168,13 +168,7 @@ public abstract class FileCopyUtils { @@ -168,13 +168,7 @@ public abstract class FileCopyUtils {
Assert.notNull(out, "No Writer specified");
try {
int charCount = 0;
char[] buffer = new char[BUFFER_SIZE];
int charsRead;
while ((charsRead = in.read(buffer)) != -1) {
out.write(buffer, 0, charsRead);
charCount += charsRead;
}
int charCount = (int) in.transferTo(out);
out.flush();
return charCount;
}

Loading…
Cancel
Save