Here you can find the source of closeQuietly(ImageReader iReader)
Parameter | Description |
---|---|
iReader | Can be <code>null</code>. |
public static void closeQuietly(ImageReader iReader)
//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 } } }