@@ -2497,13 +2497,13 @@ public static byte[] toByteArray(final InputStream inputStream) throws IOExcepti
24972497
24982498 /**
24992499 * Gets the contents of an {@code InputStream} as a {@code byte[]}. Use this method instead of
2500- * {@code toByteArray(InputStream)} when {@code InputStream} size is known
2500+ * {@code toByteArray(InputStream)} when {@code InputStream} size is known.
25012501 *
25022502 * @param input the {@code InputStream} to read.
2503- * @param size the size of {@code InputStream}.
2504- * @return the requested byte array .
2505- * @throws IOException if an I/O error occurs or {@code InputStream} size differ from parameter size.
2506- * @throws IllegalArgumentException if size is less than zero.
2503+ * @param size the size of {@code InputStream} to read, where 0 < {@code size} <= length of input stream .
2504+ * @return byte [] of length {@code size} .
2505+ * @throws IOException if an I/O error occurs or {@code InputStream} length is smaller than parameter {@code size} .
2506+ * @throws IllegalArgumentException if {@code size} is less than zero.
25072507 * @since 2.1
25082508 */
25092509 public static byte [] toByteArray (final InputStream input , final int size ) throws IOException {
@@ -2540,10 +2540,9 @@ public static byte[] toByteArray(final InputStream input, final int size) throws
25402540 * (Arrays can have no more than Integer.MAX_VALUE entries anyway)
25412541 *
25422542 * @param input the {@code InputStream} to read from
2543- * @param size the size of {@code InputStream}
2544- * @return the requested byte array
2545- * @throws IOException if an I/O error occurs or {@code InputStream} size differ from parameter
2546- * size
2543+ * @param size the size of {@code InputStream} to read, where 0 < {@code size} <= min(Integer.MAX_VALUE, length of input stream).
2544+ * @return byte [] the requested byte array, of length {@code size}
2545+ * @throws IOException if an I/O error occurs or {@code InputStream} length is less than {@code size}
25472546 * @throws IllegalArgumentException if size is less than zero or size is greater than Integer.MAX_VALUE
25482547 * @see IOUtils#toByteArray(java.io.InputStream, int)
25492548 * @since 2.1
0 commit comments