Skip to content

Commit 81ba7d7

Browse files
author
Gary Gregory
committed
- IOUtils.toByteArray(InputStream) should used an unsynchronized
ByteArrayOutputStream internally. - Improve Javadoc for IOUtils.copy(InputStream OutputStream).
1 parent 587a035 commit 81ba7d7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.apache.commons.io.output.ByteArrayOutputStream;
5656
import org.apache.commons.io.output.NullOutputStream;
5757
import org.apache.commons.io.output.StringBuilderWriter;
58+
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
5859

5960
/**
6061
* General IO stream manipulation utilities.
@@ -941,7 +942,7 @@ public static boolean contentEqualsIgnoreEOL(final Reader reader1, final Reader
941942
*
942943
* @param inputStream the {@code InputStream} to read.
943944
* @param outputStream the {@code OutputStream} to write.
944-
* @return the number of bytes copied, or -1 if > Integer.MAX_VALUE.
945+
* @return the number of bytes copied, or -1 if greater than {@link Integer#MAX_VALUE}.
945946
* @throws NullPointerException if the InputStream is {@code null}.
946947
* @throws NullPointerException if the OutputStream is {@code null}.
947948
* @throws IOException if an I/O error occurs.
@@ -2396,7 +2397,7 @@ public static BufferedReader toBufferedReader(final Reader reader, final int siz
23962397
* @throws IOException if an I/O error occurs.
23972398
*/
23982399
public static byte[] toByteArray(final InputStream inputStream) throws IOException {
2399-
try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
2400+
try (final UnsynchronizedByteArrayOutputStream output = new UnsynchronizedByteArrayOutputStream()) {
24002401
copy(inputStream, output);
24012402
return output.toByteArray();
24022403
}

0 commit comments

Comments
 (0)