Skip to content

Commit

Permalink
[IO-697] Fix IOUtils.toByteArray documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
otter606 authored and kinow committed Mar 25, 2022
1 parent c7cb67f commit 9400501
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/main/java/org/apache/commons/io/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2497,13 +2497,13 @@ public static byte[] toByteArray(final InputStream inputStream) throws IOExcepti

/**
* Gets the contents of an {@code InputStream} as a {@code byte[]}. Use this method instead of
* {@code toByteArray(InputStream)} when {@code InputStream} size is known
* {@code toByteArray(InputStream)} when {@code InputStream} size is known.
*
* @param input the {@code InputStream} to read.
* @param size the size of {@code InputStream}.
* @return the requested byte array.
* @throws IOException if an I/O error occurs or {@code InputStream} size differ from parameter size.
* @throws IllegalArgumentException if size is less than zero.
* @param size the size of {@code InputStream} to read, where 0 < {@code size} <= length of input stream.
* @return byte [] of length {@code size}.
* @throws IOException if an I/O error occurs or {@code InputStream} length is smaller than parameter {@code size}.
* @throws IllegalArgumentException if {@code size} is less than zero.
* @since 2.1
*/
public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
Expand Down Expand Up @@ -2540,10 +2540,9 @@ public static byte[] toByteArray(final InputStream input, final int size) throws
* (Arrays can have no more than Integer.MAX_VALUE entries anyway)
*
* @param input the {@code InputStream} to read from
* @param size the size of {@code InputStream}
* @return the requested byte array
* @throws IOException if an I/O error occurs or {@code InputStream} size differ from parameter
* size
* @param size the size of {@code InputStream} to read, where 0 < {@code size} <= min(Integer.MAX_VALUE, length of input stream).
* @return byte [] the requested byte array, of length {@code size}
* @throws IOException if an I/O error occurs or {@code InputStream} length is less than {@code size}
* @throws IllegalArgumentException if size is less than zero or size is greater than Integer.MAX_VALUE
* @see IOUtils#toByteArray(java.io.InputStream, int)
* @since 2.1
Expand Down

0 comments on commit 9400501

Please sign in to comment.