StreamUtil { public static void cleanUp(Closeable... closeables) throws IOException { IOException ioException1 = null; for (Closeable closeable : closeables) { if (closeable != null) { try { closeable.close(); } catch (IOException ioException2) { if (ioException1 == null) { ioException1 = ioException2; } else { ioException1.addSuppressed(ioException2); } } } } if (ioException1 == null) { return; } throw ioException1; }  static void cleanUp(Closeable... closeables); static byte[] toByteArray(InputStream inputStream); static String toString(InputStream inputStream); static String toString(InputStream inputStream, String charsetName); static void transfer(
			InputStream inputStream, OutputStream outputStream); static void transfer(
			InputStream inputStream, OutputStream outputStream, boolean cleanUp); static void transfer(
			InputStream inputStream, OutputStream outputStream, int bufferSize); static void transfer(
			InputStream inputStream, OutputStream outputStream, int bufferSize,
			boolean cleanUp); static void transfer(
			InputStream inputStream, OutputStream outputStream, int bufferSize,
			boolean cleanUp, long length); static void transfer(
			InputStream inputStream, OutputStream outputStream, long length); static final int BUFFER_SIZE; static final boolean FORCE_TIO; }
@Test public void testCleanUp() throws IOException { StreamUtil.cleanUp(new Closeable[] {null}); IOException ioException1 = new IOException(); IOException ioException2 = new IOException(); try { StreamUtil.cleanUp( () -> { throw ioException1; }, () -> { }, () -> { throw ioException2; }); Assert.fail(); } catch (IOException ioException3) { Assert.assertSame(ioException1, ioException3); Throwable[] throwables = ioException3.getSuppressed(); Assert.assertEquals( Arrays.toString(throwables), 1, throwables.length); Assert.assertSame(ioException2, throwables[0]); } }