IoUtils { public static void tryFlush(final Object... flushable) { for (final Object obj : flushable) { try { if (obj instanceof Flushable) { ((Flushable) obj).flush(); } } catch (final Throwable th) { logger.trace("Ignore exception: {}", th); } } }  static void tryFlush(final Object... flushable); static int stream(final InputStream in, final StreamConsumer consumer); static int redirect(final InputStream from, final OutputStream to); static int redirect(final Reader from, final Writer to); static byte[] from(
      final InputStream in); static String from(
      final Reader reader); static byte[] getChecksum(final InputStream in); static String getChecksumAsString(final InputStream in);  }
@Test public void testTryFlush() { final Object[][] testParameters = new Object[][] {{new Object[] {new TestFlushable()}, true}, {new Object[] {new TestFlushable(), new TestFlushable()}, true}, {new Object[] {new TestFlushable(), new TestFlushable(), new TestFlushable()}, true}}; for (final Object[] testParameter : testParameters) { boolean expected = (Boolean) testParameter[1]; Object[] flushable = (Object[]) testParameter[0]; for (int i = 0; i < flushable.length; ++i) { if (flushable[i] instanceof Flushable) { TestFlushable testFlushable = (TestFlushable) flushable[i]; assertFalse(testFlushable.isFlushed); } } IoUtils.tryFlush(flushable); for (int i = 0; i < flushable.length; ++i) { if (flushable[i] instanceof Flushable) { TestFlushable testFlushable = (TestFlushable) flushable[i]; assertEquals(expected, testFlushable.isFlushed); } } } }