Skip to content

Commit 715ecb7

Browse files
committed
Reuse IOUtils.toByteArray(InputStream)
1 parent b20eaaa commit 715ecb7

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/test/java/org/apache/commons/codec/binary/BaseNTestData.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717

1818
package org.apache.commons.codec.binary;
1919

20-
import java.io.ByteArrayOutputStream;
2120
import java.io.IOException;
2221
import java.io.InputStream;
2322
import java.util.Random;
2423

24+
import org.apache.commons.io.IOUtils;
25+
2526
/**
2627
* Data and functions common to BaseN tests.
2728
*/
@@ -140,13 +141,7 @@ private static byte[] resizeArray(final byte[] bytes) {
140141
* @throws IOException if an error occurs whilst reading the input stream
141142
*/
142143
static byte[] streamToBytes(final InputStream in) throws IOException {
143-
final ByteArrayOutputStream os = new ByteArrayOutputStream();
144-
final byte[] buf = new byte[4096];
145-
int read;
146-
while ((read = in.read(buf)) > -1) {
147-
os.write(buf, 0, read);
148-
}
149-
return os.toByteArray();
144+
return IOUtils.toByteArray(in);
150145
}
151146

152147
/**

0 commit comments

Comments
 (0)