Author: julien(a)jboss.com
Date: 2008-04-18 07:49:14 -0400 (Fri, 18 Apr 2008)
New Revision: 10640
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java
Log:
replace on IOTools safeClose(reader/inputstream/outputstream/writer) with
safeClose(Closeable)
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java
===================================================================
---
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java 2008-04-18
10:41:57 UTC (rev 10639)
+++
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java 2008-04-18
11:49:14 UTC (rev 10640)
@@ -41,6 +41,7 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ObjectStreamClass;
+import java.io.Closeable;
/**
* IO tools.
@@ -120,12 +121,12 @@
}
/**
- * <p>Attempt to close an <code>OutputStream</code>. Null argument
value is authorized and no operation will be performed in that
- * use case.</p>
+ * <p>Attempt to close an {@link Closeable} object. Null argument value is
authorized and no operation will be performed in that
+ * use case. {@link IOException} thrown are logged using the
<code>error</code> level but not propagated.</p>
*
* @param out the stream to close
*/
- public static void safeClose(OutputStream out)
+ public static void safeClose(Closeable out)
{
if (out != null)
{
@@ -141,69 +142,6 @@
}
/**
- * <p>Attempt to close an <code>InputStream</code>. Null argument
value is authorized and no operation will be performed in that
- * use case.</p>
- *
- * @param in the stream to close
- */
- public static void safeClose(InputStream in)
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (IOException e)
- {
- log.error("Error while closing inputstream", e);
- }
- }
- }
-
- /**
- * <p>Attempt to close an <code>Reader</code>. Null argument value
is authorized and no operation will be performed in that
- * use case.</p>
- *
- * @param reader the stream to close
- */
- public static void safeClose(Reader reader)
- {
- if (reader != null)
- {
- try
- {
- reader.close();
- }
- catch (IOException e)
- {
- log.error("Error while closing reader", e);
- }
- }
- }
-
- /**
- * <p>Attempt to close an <code>Writer</code>. Null argument value
is authorized and no operation will be performed in that
- * use case.</p>
- *
- * @param writer the stream to close
- */
- public static void safeClose(Writer writer)
- {
- if (writer != null)
- {
- try
- {
- writer.close();
- }
- catch (IOException e)
- {
- log.error("Error while closing writer", e);
- }
- }
- }
-
- /**
* @see #getBytes(java.io.InputStream, int)
* @param in the input stream
* @return the bytes read from the stream
Show replies by date