View Javadoc

1   /**
2    *  BlueCove - Java library for Bluetooth
3    *  Copyright (C) 2006-2008 Vlad Skarzhevskyy
4    * 
5    *  Licensed to the Apache Software Foundation (ASF) under one
6    *  or more contributor license agreements.  See the NOTICE file
7    *  distributed with this work for additional information
8    *  regarding copyright ownership.  The ASF licenses this file
9    *  to you under the Apache License, Version 2.0 (the
10   *  "License"); you may not use this file except in compliance
11   *  with the License.  You may obtain a copy of the License at
12   *
13   *    http://www.apache.org/licenses/LICENSE-2.0
14   *
15   *  Unless required by applicable law or agreed to in writing,
16   *  software distributed under the License is distributed on an
17   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   *  KIND, either express or implied.  See the License for the
19   *  specific language governing permissions and limitations
20   *  under the License.
21   *
22   *  @author vlads
23   *  @version $Id: IOUtils.java 2471 2008-12-01 03:44:20Z skarzhevskyy $
24   */
25  package net.sf.bluecove.obex;
26  
27  import java.io.IOException;
28  import java.io.InputStream;
29  
30  /**
31   * 
32   */
33  public abstract class IOUtils {
34  
35  	/**
36  	 * Unconditionally close an <code>InputStream</code>.
37  	 * <p>
38  	 * Equivalent to {@link InputStream#close()}, except any exceptions will be
39  	 * ignored. This is typically used in finally blocks.
40  	 * 
41  	 * @param input
42  	 *            the InputStream to close, may be null or already closed
43  	 */
44  	public static void closeQuietly(InputStream input) {
45  		try {
46  			if (input != null) {
47  				input.close();
48  			}
49  		} catch (IOException ignore) {
50  			// ignore
51  		}
52  	}
53  
54  }