/** * Safely close a socket, absorbing exceptions and handling * <code>null</code> graciously. * * @param socket object to close. */ public static void safeClose(Socket socket) { try { if (socket != null) { socket.close(); } } catch (IOException e) { log(socket, e); } }
/** * Safely close, absorbing exceptions and handling <code>null</code> * graciously. * * @param object object to close. */ public static void safeClose(Closeable object) { try { if (object != null) { object.close(); } } catch (IOException e) { log(object, e); } }
/** * Safely close a JDBC Statement, absorbing exceptions and handling * <code>null</code> graciously. * * @param statement * to close. */ public static void safeClose(Statement statement) { try { if (statement != null) { statement.close(); } } catch (SQLException e) { log(statement, e); } }
/** * Safely close a server socket, absorbing exceptions and handling * <code>null</code> graciously. * * @param socket object to close. */ public static void safeClose(ServerSocket socket) { try { if (socket != null) { socket.close(); } } catch (IOException e) { log(socket, e); } }
/** * Safely flush, absorbing smells, sounds, exceptions and handling <code>null</code> * graciously. * * @param object object to close. */ public static void safeFlush(Flushable object) { try { if (object != null) { object.flush(); } } catch (IOException e) { log(object, e); } }
/** * Safely close an ImageInputStream stream, absorbing exceptions and * handling <code>null</code> graciously. * * @param is to close. */ public static void safeClose(ImageInputStream is) { try { if (is != null) { is.close(); } } catch (IOException e) { log(is, e); } }