You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pe...@apache.org on 2010/11/06 14:58:34 UTC

svn commit: r1032057 - /wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/IOUtils.java

Author: pete
Date: Sat Nov  6 13:58:34 2010
New Revision: 1032057

URL: http://svn.apache.org/viewvc?rev=1032057&view=rev
Log:
since wicket-1.5 required java 1.5 we can replace all these occurences of IOUtils.closeQuietly(...) with one single IOUtils.closeQuietly(Closeable) will will not only reduce code duplication but also make it more versatile

Modified:
    wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/IOUtils.java

Modified: wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/IOUtils.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/IOUtils.java?rev=1032057&r1=1032056&r2=1032057&view=diff
==============================================================================
--- wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/IOUtils.java (original)
+++ wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/IOUtils.java Sat Nov  6 13:58:34 2010
@@ -16,18 +16,7 @@
  */
 package org.apache.wicket.util.io;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-
+import java.io.*;
 
 /**
  * General IO Stream manipulation.
@@ -82,95 +71,24 @@ public final class IOUtils
 	{
 	}
 
-	// -----------------------------------------------------------------------
 	/**
-	 * Unconditionally close an <code>Reader</code>.
+	 * Unconditionally close a <code>Closeable</code>.
 	 * <p>
-	 * Equivalent to {@link Reader#close()}, except any exceptions will be ignored. This is
+	 * closeables can be input or output streams, reader, writers, and much more.
+	 *
+	 * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is
 	 * typically used in finally blocks.
 	 * 
-	 * @param input
-	 *            the Reader to close, may be null or already closed
-	 */
-	public static void closeQuietly(Reader input)
-	{
-		if (input != null)
-		{
-			try
-			{
-				input.close();
-			}
-			catch (Exception e)
-			{
-				// ignore
-			}
-		}
-	}
-
-	/**
-	 * Unconditionally close a <code>Writer</code>.
-	 * <p>
-	 * Equivalent to {@link Writer#close()}, except any exceptions will be ignored. This is
-	 * typically used in finally blocks.
-	 * 
-	 * @param output
-	 *            the Writer to close, may be null or already closed
-	 */
-	public static void closeQuietly(Writer output)
-	{
-		if (output != null)
-		{
-			try
-			{
-				output.close();
-			}
-			catch (Exception e)
-			{
-				// ignore
-			}
-		}
-	}
-
-	/**
-	 * Unconditionally close an <code>InputStream</code>.
-	 * <p>
-	 * Equivalent to {@link InputStream#close()}, except any exceptions will be ignored. This is
-	 * typically used in finally blocks.
-	 * 
-	 * @param input
-	 *            the InputStream to close, may be null or already closed
-	 */
-	public static void closeQuietly(InputStream input)
-	{
-		if (input != null)
-		{
-			try
-			{
-				input.close();
-			}
-			catch (Exception e)
-			{
-				// ignore
-			}
-		}
-	}
-
-	/**
-	 * Unconditionally close an <code>OutputStream</code>.
-	 * <p>
-	 * Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored. This is
-	 * typically used in finally blocks.
-	 * 
-	 * @param output
-	 *            the OutputStream to close, may be null or already closed
+	 * @param closeable
+	 *            the Closeable to close, may be null or already closed
 	 */
-	public static void closeQuietly(OutputStream output)
+	public static void closeQuietly(Closeable closeable)
 	{
-		if (output != null)
+		if (closeable != null)
 		{
 			try
 			{
-				output.close();
+				closeable.close();
 			}
 			catch (Exception e)
 			{