Java Stream Close closeNoThrow(InputStream s)

Here you can find the source of closeNoThrow(InputStream s)

Description

close No Throw

License

Open Source License

Declaration

public static void closeNoThrow(InputStream s) 

Method Source Code

//package com.java2s;
/* MarcWorx MARC Library - Utilities for manipulation of MARC records
 Copyright (C) 2013  Todd Walker, Talwood Solutions

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version./*from  w w  w .  j  a  va  2  s.c o m*/

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.io.Writer;

public class Main {
    public static void closeNoThrow(InputStream s) {
        try {
            if (s != null) {
                s.close();
            }
        } catch (Exception ex) {
        }
    }

    public static void closeNoThrow(RandomAccessFile s) {
        try {
            if (s != null) {
                s.close();
            }
        } catch (Exception ex) {
        }
    }

    public static void closeNoThrow(OutputStream s) {
        try {
            if (s != null) {
                s.close();
            }
        } catch (Exception ex) {
        }
    }

    public static void closeNoThrow(Reader reader) {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (Exception ex) {
        }
    }

    public static void closeNoThrow(Writer writer) {
        try {
            if (writer != null) {
                writer.close();
            }
        } catch (Exception ex) {
        }
    }
}

Related

  1. closeLog()
  2. closeLog()
  3. closeLog()
  4. closeNoException(Closeable... closeables)
  5. closeNoExceptions(Reader reader)
  6. closeOutput(OutputStream stream)
  7. closeOutputFile(Writer pWriter)
  8. closeOutputStream(OutputStream out)
  9. closeOutputStream(OutputStream out, boolean flush)