Java Stream Close closeQuietly(BufferedReader br)

Here you can find the source of closeQuietly(BufferedReader br)

Description

close Quietly

License

Apache License

Declaration

public static void closeQuietly(BufferedReader br) 

Method Source Code

//package com.java2s;
/**/*from  www.  j  a va2  s.c  om*/
 * Copyright (c) 2015-2017 Inria
 * <p>
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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.
 * <p>
 * Contributors:
 * - Christophe Gourdin <christophe.gourdin@inria.fr>
 */

import java.io.*;

public class Main {
    /**
     * Close quietly an inputstream without exception thrown.
     *
     * @param in
     */
    public static void closeQuietly(InputStream in) {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                /* ignore */
            }
        }
    }

    public static void closeQuietly(BufferedReader br) {
        if (br != null) {
            try {
                br.close();
            } catch (IOException e) {
                /* ignore */
            }
        }
    }

    public static void closeQuietly(Reader r) {
        if (r != null) {
            try {
                r.close();
            } catch (IOException e) {
                /* ignore */
            }
        }
    }

    /**
     * Close quietly an outputstream without exception thrown.
     *
     * @param os
     */
    public static void closeQuietly(OutputStream os) {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                /* ignore */
            }
        }
    }
}

Related

  1. closeProcessStreams(Process p)
  2. closeProofWriter(Writer out)
  3. closeProtectedStream(final OutputStream outputStream)
  4. closeQietly(ZipFile zipFile)
  5. closeQuietly(@Nullable ObjectInput in)
  6. closeQuietly(Closeable input, Logger log)
  7. closeQuietly(Closeable stream)
  8. closeQuietly(Closeable stream)
  9. closeQuietly(final InputStream in)