IOUtils { public static void closeStreams(java.io.Closeable... streams) { if (streams != null) { cleanupWithLogger(null, streams); } }  static void copyBytes(InputStream in, OutputStream out,
                               int buffSize, boolean close); static void copyBytes(InputStream in, OutputStream out, int buffSize); static void copyBytes(InputStream in, OutputStream out, Configuration conf); static void copyBytes(InputStream in, OutputStream out, Configuration conf, boolean close); static void copyBytes(InputStream in, OutputStream out, long count,
      boolean close); static int wrappedReadForCompressedData(InputStream is, byte[] buf,
      int off, int len); static void readFully(InputStream in, byte[] buf,
      int off, int len); static void skipFully(InputStream in, long len); @Deprecated static void cleanup(Log log, java.io.Closeable... closeables); static void cleanupWithLogger(Logger logger,
      java.io.Closeable... closeables); static void closeStream(java.io.Closeable stream); static void closeStreams(java.io.Closeable... streams); static void closeSocket(Socket sock); static void writeFully(WritableByteChannel bc, ByteBuffer buf); static void writeFully(FileChannel fc, ByteBuffer buf,
      long offset); static List<String> listDirectory(File dir, FilenameFilter filter); static void fsync(File fileToSync); static void fsync(FileChannel channel, boolean isDir); static IOException wrapException(final String path,
      final String methodName, final IOException exception); static byte[] readFullyToByteArray(DataInput in); static final Logger LOG; }
@Test public void testCloseStreams() throws IOException { File tmpFile = null; FileOutputStream fos; BufferedOutputStream bos; FileOutputStream nullStream = null; try { tmpFile = new File(GenericTestUtils.getTestDir(), "testCloseStreams.txt"); fos = new FileOutputStream(tmpFile) { @Override public void close() throws IOException { throw new IOException(); } }; bos = new BufferedOutputStream( new FileOutputStream(tmpFile)) { @Override public void close() { throw new NullPointerException(); } }; IOUtils.closeStreams(fos, bos, nullStream); IOUtils.closeStreams(); } finally { FileUtils.deleteQuietly(tmpFile); } }