Here you can find the source of close(final Object stream)
Parameter | Description |
---|---|
stream | The object to close if it is closeable. |
Parameter | Description |
---|---|
IOException | If an error occurred while closing the stream. |
public static void close(final Object stream) throws IOException
//package com.java2s; /*//ww w . j a v a 2 s .c om * Geotoolkit.org - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2008-2012, Open Source Geospatial Foundation (OSGeo) * (C) 2009-2012, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library 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 * Lesser General Public License for more details. */ import java.io.*; public class Main { /** * Closes the given stream if it is closeable, or do nothing otherwise. Closeable * objects are any instance of {@link Closeable}. * * @param stream The object to close if it is closeable. * @throws IOException If an error occurred while closing the stream. * * @since 3.07 */ public static void close(final Object stream) throws IOException { if (stream instanceof Closeable) { ((Closeable) stream).close(); } // On JDK6, we needed an explicit check for ImageInputStream. // Since JDK7, this is not needed anymore. } }