Java Stream Close closeQuietly(ImageReader iReader)

Here you can find the source of closeQuietly(ImageReader iReader)

Description

Unconditionally close the desired ImageReader .

License

Apache License

Parameter

Parameter Description
iReader Can be <code>null</code>.

Declaration

public static void closeQuietly(ImageReader iReader) 

Method Source Code

//package com.java2s;
/*/*from   w  ww  . j  ava 2 s .c om*/
 *  -------------------------------------------------------------------------------
    
   This code is licensed under the Apache License, Version 2.0 (the "License"); 
   You may not use this file except in compliance with the License. 
    
   You may obtain a copy of the License at 
    
   http://www.apache.org/licenses/LICENSE-2.0 
    
   Unless required by applicable law or agreed to in writing, software 
   distributed under the License is distributed on an "AS IS" BASIS, 
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
   See the License for the specific language governing permissions and 
   limitations under the License.
       
 *  -------------------------------------------------------------------------------
 */

import java.io.Closeable;
import java.io.IOException;

import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;

public class Main {
    /**
     * Unconditionally close the desired {@link Closeable}.
     * 
     * @param closeable
     *            Can be <code>null</code>.
     */
    public static void closeQuietly(Closeable closeable) {
        if (closeable == null)
            return;
        try {
            closeable.close();
        } catch (IOException e) {
            // irrelevant
        }
    }

    /**
     * Unconditionally close the desired {@link ImageReader}.
     * 
     * @param iReader
     *            Can be <code>null</code>.
     */
    public static void closeQuietly(ImageReader iReader) {
        if (iReader == null)
            return;
        try {
            iReader.dispose();
        } catch (Exception e) {
            // irrelevant
        }
    }

    /**
     * Unconditionally close the desired {@link ImageInputStream}.
     * 
     * @param ii
     *            Can be <code>null</code>.
     */
    public static void closeQuietly(ImageInputStream ii) {
        if (ii == null)
            return;
        try {
            ii.close();
        } catch (IOException e) {
            // irrelevant
        }
    }
}

Related

  1. closeQuietly(final InputStream in)
  2. closeQuietly(final InputStream inputStream)
  3. closeQuietly(final Reader reader)
  4. closeQuietly(final ZipFile... zipFiles)
  5. closeQuietly(ImageInputStream ins)
  6. closeQuietly(InputStream c)
  7. closeQuietly(InputStream in)
  8. closeQuietly(InputStream in)
  9. closeQuietly(InputStream input)