Reads and discards data from the given {@code InputStream} until the end of the stream is reached. Returns the total number of bytes read. Does not close the stream. @since 20.0
(InputStream in)
| 287 | * @since 20.0 |
| 288 | */ |
| 289 | @CanIgnoreReturnValue |
| 290 | public static long exhaust(InputStream in) throws IOException { |
| 291 | long total = 0; |
| 292 | long read; |
| 293 | byte[] buf = createBuffer(); |
| 294 | while ((read = in.read(buf)) != -1) { |
| 295 | total += read; |
| 296 | } |
| 297 | return total; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Returns a new {@link ByteArrayDataInput} instance to read from the {@code bytes} array from the |
no test coverage detected