Here you can find the source of close(InputStream inputstream)
Parameter | Description |
---|---|
IOException | an exception |
public static void close(InputStream inputstream) throws IOException
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.io.InputStream; public class Main { /**/*from ww w . j a va 2 s . c o m*/ * Closes an input stream while inspecting its class. The inspection is done * to avoid closing streams associates with jar files that may cause later * errors like * * <pre> * Caused by: java.io.IOException: Stream closed * </pre> * * So, all streams whose class name does not start with * <code>sun.net.www.protocol.jar.JarURLConnection</code> will be closed * * @throws IOException * * @since 2016-09-20 */ public static void close(InputStream inputstream) throws IOException { if (inputstream != null) { String inputstreamClassName = inputstream.getClass().getName(); if (!inputstreamClassName.startsWith("sun.net.www.protocol.jar.JarURLConnection")) { inputstream.close(); } } } }