Java Stream Close closeNoExceptions(Reader reader)

Here you can find the source of closeNoExceptions(Reader reader)

Description

close No Exceptions

License

Open Source License

Declaration

public static void closeNoExceptions(Reader reader) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009  Clark N. Hobbie/*www  .j  a  v  a2  s. com*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Clark N. Hobbie - initial API and implementation
 *******************************************************************************/

import java.io.BufferedReader;

import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import java.io.Reader;

public class Main {
    public static void closeNoExceptions(Reader reader) {
        if (null == reader)
            return;

        try {
            reader.close();
        } catch (IOException e) {
            ; // ignore exceptions
        }
    }

    public static void closeNoExceptions(BufferedReader reader) {
        if (null == reader)
            return;

        try {
            reader.close();
        } catch (IOException e) {
            ; // this method is supposed to ignore exceptions
        }
    }

    public static void closeNoExceptions(InputStream istream) {
        if (null == istream)
            return;

        try {
            istream.close();
        } catch (IOException e) {
            ; // this method is supposed to ignore exceptions
        }
    }

    public static void closeNoExceptions(FileWriter writer) {
        if (null == writer)
            return;

        try {
            writer.close();
        } catch (IOException e) {
            ; // the point of this method is to avoid throwing exceptions
        }
    }

    public static void closeNoExceptions(OutputStream ostream) {
        try {
            ostream.close();
        } catch (IOException e) {
            ;
        }
    }
}

Related

  1. closeKeyMap(BufferedReader in)
  2. closeLog()
  3. closeLog()
  4. closeLog()
  5. closeNoException(Closeable... closeables)
  6. closeNoThrow(InputStream s)
  7. closeOutput(OutputStream stream)
  8. closeOutputFile(Writer pWriter)
  9. closeOutputStream(OutputStream out)