moved similiar code to a utility function to remove code duplication

This commit is contained in:
Jeremy Long
2016-12-04 11:28:53 -05:00
parent 4dd6dedaa4
commit a271d422f6
4 changed files with 32 additions and 78 deletions

View File

@@ -17,6 +17,7 @@
*/
package org.owasp.dependencycheck.utils;
import java.io.Closeable;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -131,4 +132,20 @@ public final class FileUtils {
return BIT_BUCKET_UNIX;
}
}
/**
* Close the given {@link Closeable} instance, ignoring nulls, and logging
* any thrown {@link IOException}.
*
* @param closeable to be closed
*/
public static void close(Closeable closeable) {
if (null != closeable) {
try {
closeable.close();
} catch (IOException ex) {
LOGGER.trace("", ex);
}
}
}
}