Here you can find the source of closeQuietly(@Nullable ObjectInput in)
Parameter | Description |
---|---|
in | the closeable to close. |
public void closeQuietly(@Nullable ObjectInput in)
//package com.java2s; /*/*from www . jav a2s .com*/ * IOUtilities.java - IO related functions * :tabSize=4:indentSize=4:noTabs=false: * :folding=explicit:collapseFolds=1: * * Copyright (C) 2006 Matthieu Casanova * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.io.*; import javax.annotation.Nullable; public class Main { /** * Method that will close a {@link java.io.Closeable} ignoring it if it is null and ignoring exceptions. * * @param closeable the closeable to close. * @since jEdit 4.3pre8 */ public static void closeQuietly(@Nullable Closeable closeable) { if (closeable != null) { try { if (closeable instanceof Flushable) { ((Flushable) closeable).flush(); } } catch (IOException e) { // ignore } try { closeable.close(); } catch (IOException e) { //ignore } } } /** * Method that will close an {@link ObjectInput} ignoring it if it is null and ignoring exceptions. * * @param in the closeable to close. * @since jEdit 5.1pre1 */ public void closeQuietly(@Nullable ObjectInput in) { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } /** * Method that will close an {@link ObjectOutput} ignoring it if it is null and ignoring exceptions. * @param out the closeable to close. * @since jEdit 5.1pre1 */ public void closeQuietly(@Nullable ObjectOutput out) { if (out != null) { try { out.close(); } catch (IOException e) { // ignore } } } }