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>
This commit is contained in:
Patrick Strawderman
2026-01-22 21:28:41 -06:00
committed by Brian Clozel
parent bc01eeb433
commit 96fb5d72eb
@@ -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;
}