Java Utililty Methods Stream Close

List of utility methods to do Stream Close

Description

The list of methods to do Stream Close are organized into topic(s).

Method

voidcloseSafely(final FileOutputStream output)
close Safely
if (output != null) {
    try {
        output.flush();
        output.close();
    } catch (final IOException e) {
voidcloseSafely(InputStream is)
close Safely
try {
    if (is != null)
        is.close();
} catch (Throwable e) {
voidcloseSafely(ZipInputStream zis)
close Safely
if (zis != null) {
    try {
        zis.closeEntry();
    } catch (IOException e) {
    try {
        zis.close();
    } catch (IOException e) {
...
voidcloseSecurityConfigurationFileInputStream(FileInputStream fis)
Close the security.properties input stream once it's been used.
if (fis != null) {
    try {
        fis.close();
    } catch (Exception ignoreMe) {
voidcloseSilently(final InputStream is)
close Silently
if (is != null) {
    try {
        is.close();
    } catch (final IOException ignored) {
voidcloseSilently(InputStream in)
close Silently
if (null != in) {
    try {
        in.close();
    } catch (IOException e) {
voidcloseSilently(InputStream inputStream)
Closes the given stream.
try {
    if (inputStream != null) {
        inputStream.close();
} catch (IOException ignore) {
voidcloseSilently(InputStream... inputStreams)
close Silently
for (InputStream inputStream : inputStreams) {
    if (inputStream != null) {
        try {
            inputStream.close();
        } catch (IOException e) {
voidcloseSilently(java.util.logging.Logger log, Closeable stream)
Closes the Closable and logs the exception if any
if (stream != null) {
    try {
        stream.close();
    } catch (IOException e) {
        log.log(Level.WARNING, e.getLocalizedMessage(), e.getCause());
voidcloseSilently(Object obj, Closeable stream)
close Silently
if (stream == null) {
    return;
try {
    stream.close();
} catch (IOException e) {
    Logger.getLogger(obj.getClass().getName()).log(Level.WARNING, "Error occured while closing a stream.",
            e);
...