Skip to content

Commit 436b36f

Browse files
author
Gary Gregory
committed
Javadoc exceptions.
1 parent 4b92e65 commit 436b36f

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -853,15 +853,15 @@ public static boolean contentEqualsIgnoreEOL(final Reader input1, final Reader i
853853
* use the <code>copyLarge(InputStream, OutputStream)</code> method.
854854
* </p>
855855
*
856-
* @param input the <code>InputStream</code> to read from
857-
* @param output the <code>OutputStream</code> to write to
856+
* @param inputStream the <code>InputStream</code> to read from
857+
* @param outputStream the <code>OutputStream</code> to write to
858858
* @return the number of bytes copied, or -1 if &gt; Integer.MAX_VALUE, or {@code 0} if {@code input is null}.
859-
* @throws NullPointerException if the output is null
859+
* @throws NullPointerException if the OutputStream is {@code null}.
860860
* @throws IOException if an I/O error occurs
861861
* @since 1.1
862862
*/
863-
public static int copy(final InputStream input, final OutputStream output) throws IOException {
864-
final long count = copyLarge(input, output);
863+
public static int copy(final InputStream inputStream, final OutputStream outputStream) throws IOException {
864+
final long count = copyLarge(inputStream, outputStream);
865865
if (count > Integer.MAX_VALUE) {
866866
return -1;
867867
}
@@ -875,17 +875,17 @@ public static int copy(final InputStream input, final OutputStream output) throw
875875
* This method buffers the input internally, so there is no need to use a <code>BufferedInputStream</code>.
876876
* </p>
877877
*
878-
* @param input the <code>InputStream</code> to read from
879-
* @param output the <code>OutputStream</code> to write to
878+
* @param inputStream the <code>InputStream</code> to read, may be {@code null}.
879+
* @param outputStream the <code>OutputStream</code> to write to
880880
* @param bufferSize the bufferSize used to copy from the input to the output
881881
* @return the number of bytes copied. or {@code 0} if {@code input is null}.
882-
* @throws NullPointerException if the output is null
882+
* @throws NullPointerException if the OutputStream is {@code null}.
883883
* @throws IOException if an I/O error occurs
884884
* @since 2.5
885885
*/
886-
public static long copy(final InputStream input, final OutputStream output, final int bufferSize)
886+
public static long copy(final InputStream inputStream, final OutputStream outputStream, final int bufferSize)
887887
throws IOException {
888-
return copyLarge(input, output, new byte[bufferSize]);
888+
return copyLarge(inputStream, outputStream, new byte[bufferSize]);
889889
}
890890

891891
/**
@@ -1133,16 +1133,16 @@ public static int copy(final Reader input, final Writer output) throws IOExcepti
11331133
* The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
11341134
* </p>
11351135
*
1136-
* @param input the <code>InputStream</code> to read from
1137-
* @param output the <code>OutputStream</code> to write to
1136+
* @param inputStream the <code>InputStream</code> to read from
1137+
* @param outputStream the <code>OutputStream</code> to write to
11381138
* @return the number of bytes copied. or {@code 0} if {@code input is null}.
1139-
* @throws NullPointerException if the output is null
1139+
* @throws NullPointerException if the OutputStream is {@code null}.
11401140
* @throws IOException if an I/O error occurs
11411141
* @since 1.3
11421142
*/
1143-
public static long copyLarge(final InputStream input, final OutputStream output)
1143+
public static long copyLarge(final InputStream inputStream, final OutputStream outputStream)
11441144
throws IOException {
1145-
return copy(input, output, DEFAULT_BUFFER_SIZE);
1145+
return copy(inputStream, outputStream, DEFAULT_BUFFER_SIZE);
11461146
}
11471147

11481148
/**
@@ -1153,20 +1153,23 @@ public static long copyLarge(final InputStream input, final OutputStream output)
11531153
* <code>BufferedInputStream</code>.
11541154
* </p>
11551155
*
1156-
* @param input the <code>InputStream</code> to read from
1157-
* @param output the <code>OutputStream</code> to write to
1156+
* @param inputStream the <code>InputStream</code> to read, may be {@code null}.
1157+
* @param outputStream the <code>OutputStream</code> to write
11581158
* @param buffer the buffer to use for the copy
1159-
* @return the number of bytes copied. or {@code 0} if {@code input is null}.
1159+
* @return the number of bytes copied. or {@code 0} if {@code input} is {@code null}.
1160+
* @throws NullPointerException if the OutputStream is {@code null}.
11601161
* @throws IOException if an I/O error occurs
11611162
* @since 2.2
11621163
*/
1163-
public static long copyLarge(final InputStream input, final OutputStream output, final byte[] buffer)
1164+
@SuppressWarnings("resource") // streams are closed by the caller.
1165+
public static long copyLarge(final InputStream inputStream, final OutputStream outputStream, final byte[] buffer)
11641166
throws IOException {
1167+
Objects.requireNonNull(outputStream, "outputStream");
11651168
long count = 0;
1166-
if (input != null) {
1169+
if (inputStream != null) {
11671170
int n;
1168-
while (EOF != (n = input.read(buffer))) {
1169-
output.write(buffer, 0, n);
1171+
while (EOF != (n = inputStream.read(buffer))) {
1172+
outputStream.write(buffer, 0, n);
11701173
count += n;
11711174
}
11721175
}

0 commit comments

Comments
 (0)