Here you can find the source of closeSilently(OutputStream outputStream)
OutputStream
, ignoring any exceptions raised while closing.
Parameter | Description |
---|---|
outputStream | Stream to close. |
public static void closeSilently(OutputStream outputStream)
//package com.java2s; //License from project: MIT License import java.io.IOException; import java.io.OutputStream; public class Main { /**//from w w w .j a v a 2 s .c om * Closes the <code>OutputStream</code>, ignoring any exceptions raised while closing. Flushes the stream before closing it. * * @param outputStream Stream to close. */ public static void closeSilently(OutputStream outputStream) { flushSilently(outputStream); try { outputStream.close(); } catch (IOException ignored) { } } /** * Flushes the <code>OutputStream</code>, ignoring any exceptions raised while closing. * * @param outputStream Stream to flush. */ public static void flushSilently(OutputStream outputStream) { try { outputStream.flush(); } catch (IOException ignored) { } } }