Skip to content

Commit 860de72

Browse files
committed
Don't check for size twice
Javadoc
1 parent bb0304c commit 860de72

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,9 +2671,6 @@ public static byte[] toByteArray(final InputStream inputStream) throws IOExcepti
26712671
*/
26722672
@SuppressWarnings("resource")
26732673
public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
2674-
if (size == 0) {
2675-
return EMPTY_BYTE_ARRAY;
2676-
}
26772674
return toByteArray(Objects.requireNonNull(input, "input")::read, size);
26782675
}
26792676

@@ -2703,7 +2700,7 @@ public static byte[] toByteArray(final InputStream input, final long size) throw
27032700
/**
27042701
* Gets the contents of an input as a {@code byte[]}.
27052702
*
2706-
* @param input the input to read.
2703+
* @param input the input to read, not null.
27072704
* @param size the size of the input to read, where 0 < {@code size} <= length of input.
27082705
* @return byte [] of length {@code size}.
27092706
* @throws IOException if an I/O error occurs or input length is smaller than parameter {@code size}.

0 commit comments

Comments
 (0)