//
// $Id: StreamUtil.java,v 1.1 2003/05/14 21:30:29 ray Exp $

package com.samskivert.io;

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

import com.samskivert.Log;

/**
 * Convenience methods for streams.
 */
public class StreamUtil
{
    /**
     * Convenient close for a stream. Use in a finally clause and love life.
     */
    public static void close (InputStream in)
    {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ioe) {
                Log.warning("Error closing input stream [stream=" + in + ", cause=" + ioe + "].");
            }
        }
    }

    /**
     * Convenient close for a stream. Use in a finally clause and love life.
     */
    public static void close (OutputStream out)
    {
        if (out != null) {
            try {
                out.close();
            } catch (IOException ioe) {
                Log.warning("Error closing output stream [stream=" + out + ", cause=" + ioe + "].");
            }
        }
    }

    /**
     * Convenient close for a reader. Use in a finally clause and love life.
     */
    public static void close (Reader in)
    {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ioe) {
                Log.warning("Error closing input reader [reader=" + in + ", cause=" + ioe + "].");
            }
        }
    }

    /**
     * Convenient close for a writer. Use in a finally clause and love life.
     */
    public static void close (Writer out)
    {
        if (out != null) {
            try {
                out.close();
            } catch (IOException ioe) {
                Log.warning("Error closing output writer [writer=" + out + ", cause=" + ioe + "].");
            }
        }
    }
}

@@ -85,16 +85,42 @@
 rt.io;%0A%0A
+import java.io.Closeable;%0A
 import j
@@ -199,54 +199,8 @@
 eam;
-%0Aimport java.io.Reader;%0Aimport java.io.Writer;
 %0A%0Aim
@@ -1113,22 +1113,25 @@
 e for a 
-reader
+Closeable
 . Use in
@@ -1205,17 +1205,19 @@
 se (
-Reader in
+Closeable c
 )%0A  
@@ -1224,34 +1224,33 @@
   %7B%0A        if (
-in
+c
  != null) %7B%0A    
@@ -1271,34 +1271,33 @@
                 
-in
+c
 .close();%0A      
@@ -1377,422 +1377,28 @@
 ing 
-input reader %5Breader=%22 + in + %22, cause=%22 + ioe + %22%5D.%22);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Convenient close for a writer. Use in a finally clause and love life.%0A     */%0A    public static void close (Writer out)%0A    %7B%0A        if (out != null) %7B%0A            try %7B%0A                out.close();%0A            %7D catch (IOException ioe) %7B%0A                Log.warning(%22Error closing output writer %5Bwriter
+closeable %5Bobj
 =%22 + 
-out
+c
  + %22

Use the handy new Closeable interface that Ray pointed out. Left the InputStream and OutputStream versions in to avoid breaking binary compatibility.