Java Stream Close close(BufferedReader br)

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

Description

Close.

License

Apache License

Parameter

Parameter Description
br the br

Exception

Parameter Description
IOException the io exception

Declaration

public static void close(BufferedReader br) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    /**//  www  . j  a va  2  s .  c  om
     * Close.
     *
     * @param in the in
     * @throws IOException the io exception
     */
    public static void close(InputStream in) throws IOException {
        if (in == null) {
            return;
        }
        try {
            in.close();
        } catch (IOException e) {
            throw e;
        }
    }

    /**
     * Close.
     *
     * @param out the out
     * @throws IOException the io exception
     */
    public static void close(OutputStream out) throws IOException {
        if (out == null) {
            return;
        }
        try {
            out.close();
        } catch (IOException e) {
            throw e;
        }
    }

    /**
     * Close.
     *
     * @param in  the in
     * @param out the out
     * @throws IOException the io exception
     */
    public static void close(InputStream in, OutputStream out) throws IOException {
        try {
            close(in);
        } catch (IOException e) {
            throw e;
        } finally {
            try {
                close(out);
            } catch (IOException e) {
                throw e;
            }
        }
    }

    /**
     * Close.
     *
     * @param br the br
     * @throws IOException the io exception
     */
    public static void close(BufferedReader br) throws IOException {
        if (br == null) {
            return;
        }
        try {
            br.close();
        } catch (IOException e) {
            throw e;
        }
    }

    /**
     * Close.
     *
     * @param bw the bw
     * @throws IOException the io exception
     */
    public static void close(BufferedWriter bw) throws IOException {
        if (bw == null) {
            return;
        }
        try {
            bw.close();
        } catch (IOException e) {
            throw e;
        }
    }

    /**
     * Close.
     *
     * @param in  the in
     * @param out the out
     * @throws IOException the io exception
     */
    public static void close(BufferedReader in, BufferedWriter out) throws IOException {
        try {
            close(in);
        } catch (IOException e) {
            throw e;
        } finally {
            try {
                close(out);
            } catch (IOException e) {
                throw e;
            }
        }
    }
}

Related

  1. close(Appendable output)
  2. close(Appendable sb, String comp)
  3. close(BufferedReader br)
  4. close(BufferedWriter bufferedWriter)
  5. close(ClassLoader cl)
  6. close(Closeable bufferedInputStream)