|
1 | 1 | /* |
2 | | - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
25 | 25 | import java.io.OutputStream; |
26 | 26 | import java.nio.charset.Charset; |
27 | 27 |
|
28 | | -import org.springframework.lang.Contract; |
29 | 28 | import org.springframework.lang.Nullable; |
30 | 29 |
|
31 | 30 | /** |
32 | | - * Simple utility methods for dealing with streams. The copy methods of this class are |
33 | | - * similar to those defined in {@link FileCopyUtils} except that all affected streams are |
34 | | - * left open when done. All copy methods use a block size of 8192 bytes. |
| 31 | + * Simple utility methods for dealing with streams. |
| 32 | + * |
| 33 | + * <p>The copy methods of this class are similar to those defined in |
| 34 | + * {@link FileCopyUtils} except that all affected streams are left open when done. |
| 35 | + * All copy methods use a block size of {@value #BUFFER_SIZE} bytes. |
35 | 36 | * |
36 | 37 | * <p>Mainly for use within the framework, but also useful for application code. |
37 | 38 | * |
@@ -190,14 +191,14 @@ public static long copyRange(InputStream in, OutputStream out, long start, long |
190 | 191 | } |
191 | 192 |
|
192 | 193 | /** |
193 | | - * Drain the remaining content of the given InputStream. |
194 | | - * <p>Leaves the InputStream open when done. |
195 | | - * @param in the InputStream to drain |
196 | | - * @return the number of bytes read |
| 194 | + * Drain the remaining content of the given {@link InputStream}. |
| 195 | + * <p>Leaves the {@code InputStream} open when done. |
| 196 | + * @param in the {@code InputStream} to drain |
| 197 | + * @return the number of bytes read, or {@code 0} if the supplied |
| 198 | + * {@code InputStream} is {@code null} or empty |
197 | 199 | * @throws IOException in case of I/O errors |
198 | 200 | * @since 4.3 |
199 | 201 | */ |
200 | | - @Contract("null -> fail") |
201 | 202 | public static int drain(@Nullable InputStream in) throws IOException { |
202 | 203 | if (in == null) { |
203 | 204 | return 0; |
|
0 commit comments