Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96fb5d7

Browse files
kilinkbclozel
authored andcommitted
Use Reader.transferTo in FileCopyUtils
Use the transferTo method in FileCopyUtils#copy(Reader, Writer). Closes gh-36196 Signed-off-by: Patrick Strawderman <[email protected]>
1 parent bc01eeb commit 96fb5d7

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,7 @@ public static int copy(Reader in, Writer out) throws IOException {
168168
Assert.notNull(out, "No Writer specified");
169169

170170
try {
171-
int charCount = 0;
172-
char[] buffer = new char[BUFFER_SIZE];
173-
int charsRead;
174-
while ((charsRead = in.read(buffer)) != -1) {
175-
out.write(buffer, 0, charsRead);
176-
charCount += charsRead;
177-
}
171+
int charCount = (int) in.transferTo(out);
178172
out.flush();
179173
return charCount;
180174
}

0 commit comments

Comments
 (0)