org.ebay.datameta.util.jdk.JdkUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of util-jdk Show documentation
Show all versions of util-jdk Show documentation
Whatever may be missing in JDKs (and Java JDKs only), add here
The newest version!
package org.ebay.datameta.util.jdk;
import javax.annotation.Nullable;
import java.io.Closeable;
import java.io.IOException;
/**
* @author Michael Bergens
*/
public class JdkUtil {
/**
* Null-tolerant, non-disruptive close all call for the finally clause.
*
* @param errHandler error handler if any, see {@link CatchHandler}
* @param closeables to safely close (which by the way closes all related result sets) one by one, nulls ignored.
* @deprecated Use Java 7'th try-with-resources instead.
*/
@Api public void closeAll(@Nullable final CatchHandler errHandler, final Closeable... closeables) {
for (Closeable closeable : closeables) {
try {
if (closeable != null) {
closeable.close();
}
}
catch (IOException e) {
if(errHandler != null) errHandler.handle(e);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy