Java Stream Close close(Writer stream)

Here you can find the source of close(Writer stream)

Description

Close stream with the usual checks.

License

Open Source License

Parameter

Parameter Description
stream the InputStream to close - ignored if null

Return

null if closed without IOException, message otherwise

Declaration

public static String close(Writer stream) 

Method Source Code


//package com.java2s;
/* *******************************************************************
 * Copyright (c) 1999-2001 Xerox Corporation, 
 *               2002 Palo Alto Research Center, Incorporated (PARC).
 * All rights reserved. /*ww  w  .  ja v a2 s  . co m*/
 * 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: 
 *     Xerox/PARC     initial implementation 
 * ******************************************************************/

import java.io.*;

public class Main {
    /**
     * Close stream with the usual checks.
     * @param stream the InputStream to close - ignored if null 
     * @return null if closed without IOException, message otherwise 
     */
    public static String close(Writer stream) {
        String result = null;
        if (null != stream) {
            try {
                stream.close();
            } catch (IOException e) {
                result = e.getMessage();
            }
        }
        return result;
    }
}

Related

  1. close(OutputStream s)
  2. close(PrintStream writer)
  3. close(Process process)
  4. close(RandomAccessFile randomAccessFile)
  5. close(Writer out)
  6. close(ZipFile file)
  7. close(ZipFile file)
  8. close(ZipFile file)
  9. close(ZipFile zipFile)