Here you can find the source of closeStream(final Object stream)
Parameter | Description |
---|---|
stream | stream to close. |
public static void closeStream(final Object stream)
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*w ww . j av a2s.c o m*/ * Close an InputStream or OutputStream. * * @param stream * stream to close. */ public static void closeStream(final Object stream) { try { if (stream instanceof OutputStream) { OutputStream out = (OutputStream) stream; try { out.flush(); } finally { out.close(); } } else if (stream instanceof InputStream) { ((InputStream) stream).close(); } } catch (Exception e) { // ignore } } }