mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
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:
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user