Here you can find the source of close(final InputStream is)
Parameter | Description |
---|---|
is | the input stream to close |
public static void close(final InputStream is)
//package com.java2s; /*//from w w w.jav a 2 s . c om * Copyright (c) 2006 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial API and implementation */ import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; public class Main { /** * Close the Reader quietly consuming any exceptions. * * @param reader the Reader to close */ public static void close(final Reader reader) { close((Closeable) reader); } /** * Close the Writer quietly consuming any exceptions. * * @param writer the writer to close */ public static void close(final Writer writer) { close((Closeable) writer); } /** * Close the input stream quietly consuming any exceptions. * * @param is the input stream to close */ public static void close(final InputStream is) { close((Closeable) is); } /** * Close the output stream quietly consuming any exceptions. * * @param os the output stream to close */ public static void close(final OutputStream os) { close((Closeable) os); } /** * Close the given group of closable objects quietly consuming * any exceptions. * * @param closeables the closable objects to close */ public static void close(final Closeable... closeables) { if (closeables == null) { return; } for (final Closeable closeable : closeables) { close(closeable); } } /** * Closes a {@code Closeable} object quietly consuming any exceptions thrown. * @param closeable the object to close, may be null or already closed */ public static void close(final Closeable closeable) { try { if (closeable != null) closeable.close(); } catch (final IOException ignore) { } } }