net.sf.uadetector.internal.util
Class Closeables

java.lang.Object
  extended by net.sf.uadetector.internal.util.Closeables

public final class Closeables
extends java.lang.Object

This class is intended to provide utility methods to close Closeable instances.

Author:
André Rouél

Method Summary
static void close(java.io.Closeable closeable, boolean swallowIOException)
          Closes a Closeable and swallows an occurring IOException if argument swallowIOException is true, otherwise the IOException will be thrown.
static void closeAndConvert(java.io.Closeable closeable, boolean swallowIOException)
          Closes a Closeable and swallows an occurring IOException if argument swallowIOException is true, otherwise the IOException will be converted into a runtime exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public static void close(@Nullable
                         java.io.Closeable closeable,
                         boolean swallowIOException)
                  throws java.io.IOException
Closes a Closeable and swallows an occurring IOException if argument swallowIOException is true, otherwise the IOException will be thrown.

This method does nothing if a null reference is passed as closeable.

Parameters:
closeable - the Closeable object to be closed, or null
swallowIOException - true if an occurring IOException should be swallowed and logged or false to throw it
Throws:
java.io.IOException - if the given closeable cannot be closed

closeAndConvert

public static void closeAndConvert(@Nullable
                                   java.io.Closeable closeable,
                                   boolean swallowIOException)
Closes a Closeable and swallows an occurring IOException if argument swallowIOException is true, otherwise the IOException will be converted into a runtime exception.

This method does nothing if a null reference is passed as closeable.

Parameters:
closeable - the Closeable object to be closed, or null
swallowIOException - true if an occurring IOException should be swallowed and logged or false to throw a CannotCloseException
Throws:
CannotCloseException - if the given closeable cannot be closed


Copyright © 2011-2014. All Rights Reserved.