Skip to content

Commit

Permalink
Use InputStream.readAllBytes() in FileCopyUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
stsypanov committed Mar 21, 2023
1 parent 4e8162c commit 9980cb4
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,6 @@
package org.springframework.util;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -146,9 +145,9 @@ public static byte[] copyToByteArray(@Nullable InputStream in) throws IOExceptio
return new byte[0];
}

ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
copy(in, out);
return out.toByteArray();
try (in) {
return in.readAllBytes();
}
}


Expand Down

0 comments on commit 9980cb4

Please sign in to comment.