Here you can find the source of closeStream(final InputStream stream)
Parameter | Description |
---|---|
stream | InputStream to close; a null value will cause false to be returned |
public static boolean closeStream(final InputStream stream)
//package com.java2s; /*/*from w w w .j ava2s. c om*/ * Copyright (C) 2011-2014 Brian Groenke * All rights reserved. * * This file is part of the 2DX Graphics Library. * * This Source Code Form is subject to the terms of the * Mozilla Public License, v. 2.0. If a copy of the MPL * was not distributed with this file, You can obtain one at * http://mozilla.org/MPL/2.0/. */ import java.io.*; public class Main { /** * Closes the InputStream, catching the exception and returning false on * failure. In the case that stream is null, this method will quietly return * false. * * @param stream * InputStream to close; a null value will cause false to be * returned * @return true if successful, false if null or otherwise. */ public static boolean closeStream(final InputStream stream) { if (stream == null) { return false; } try { stream.close(); } catch (IOException e) { e.printStackTrace(); return false; } return true; } /** * Closes the OutputStream, catching the exception and returning false on * failure. In the case that stream is null, this method will quietly return * false. * * @param stream * OutputStream to close; a null value will cause false to be * returned * @return true if successful, false if null or otherwise. */ public static boolean closeStream(final OutputStream stream) { if (stream == null) { return false; } try { stream.close(); } catch (IOException e) { e.printStackTrace(); return false; } return true; } }