commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1076330 - in /commons/proper/net/trunk/src/main/java: examples/util/IOUtil.java org/apache/commons/net/ftp/FTPClient.java org/apache/commons/net/io/Util.java
Date Wed, 02 Mar 2011 19:04:38 GMT
Author: sebb
Date: Wed Mar  2 19:04:38 2011
New Revision: 1076330

URL: http://svn.apache.org/viewvc?rev=1076330&view=rev
Log:
Oops - added closeQuietly to the examples in error; move to io.Util

Modified:
    commons/proper/net/trunk/src/main/java/examples/util/IOUtil.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/io/Util.java

Modified: commons/proper/net/trunk/src/main/java/examples/util/IOUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/util/IOUtil.java?rev=1076330&r1=1076329&r2=1076330&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/util/IOUtil.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/util/IOUtil.java Wed Mar  2 19:04:38 2011
@@ -17,36 +17,26 @@
 
 package examples.util;
 
-import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.Socket;
-
 import org.apache.commons.net.io.Util;
 
-/**
+/***
  * This is a utility class providing a reader/writer capability required
  * by the weatherTelnet, rexec, rshell, and rlogin example programs.
+ * The only point of the class is to hold the static method readWrite
+ * which spawns a reader thread and a writer thread.  The reader thread
+ * reads from a local input source (presumably stdin) and writes the
+ * data to a remote output destination.  The writer thread reads from
+ * a remote input source and writes to a local output destination.
+ * The threads terminate when the remote input source closes.
  * <p>
- * It also contains some other common IO methods.
- */
+ ***/
 
 public final class IOUtil
 {
 
-    /**
-     * This method spawns a reader thread and a writer thread. The reader thread
-     * reads from a local input source (presumably stdin) and writes the
-     * data to a remote output destination.  The writer thread reads from
-     * a remote input source and writes to a local output destination.
-     * The threads terminate when the remote input source closes.
-     * 
-     * @param remoteInput
-     * @param remoteOutput
-     * @param localInput
-     * @param localOutput
-     */
     public static final void readWrite(final InputStream remoteInput,
                                        final OutputStream remoteOutput,
                                        final InputStream localInput,
@@ -112,34 +102,5 @@ public final class IOUtil
         }
     }
 
-    /**
-     * Closes the object quietly, catching rather than throwing IOException.
-     * Intended for use from finally blocks.
-     * 
-     * @param closeable the object to close, may be {@code null}
-     */
-    public static void closeQuietly(Closeable closeable) {
-        if (closeable != null) {
-            try {
-                closeable.close();
-            } catch (IOException e) {
-            }
-        }
-    }
-
-    /**
-     * Closes the socket quietly, catching rather than throwing IOException.
-     * Intended for use from finally blocks.
-     * 
-     * @param socket the socket to close, may be {@code null}
-     */
-    public static void closeQuietly(Socket socket) {
-        if (socket != null) {
-            try {
-                socket.close();
-            } catch (IOException e) {
-            }
-        }
-    }
 }
 

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1076330&r1=1076329&r2=1076330&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Wed Mar
 2 19:04:38 2011
@@ -42,8 +42,6 @@ import org.apache.commons.net.io.FromNet
 import org.apache.commons.net.io.ToNetASCIIOutputStream;
 import org.apache.commons.net.io.Util;
 
-import examples.util.IOUtil;
-
 /***
  * FTPClient encapsulates all the functionality necessary to store and
  * retrieve files from an FTP server.  This class takes care of all
@@ -478,7 +476,7 @@ implements Configurable
         }
         finally
         {
-            IOUtil.closeQuietly(socket);
+            Util.closeQuietly(socket);
         }
         output.close(); // we want to propagate errors from this
         return completePendingCommand();
@@ -1485,7 +1483,7 @@ implements Configurable
                     CopyStreamEvent.UNKNOWN_STREAM_SIZE, __copyStreamListener,
                     false);
         } finally {
-            IOUtil.closeQuietly(socket);
+            Util.closeQuietly(socket);
         }
         return completePendingCommand();
     }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/io/Util.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/io/Util.java?rev=1076330&r1=1076329&r2=1076330&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/io/Util.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/io/Util.java Wed Mar  2
19:04:38 2011
@@ -17,11 +17,13 @@
 
 package org.apache.commons.net.io;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.Writer;
+import java.net.Socket;
 
 /***
  * The Util class cannot be instantiated and stores short static convenience
@@ -331,4 +333,33 @@ public final class Util
         return copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
     }
 
+    /**
+     * Closes the object quietly, catching rather than throwing IOException.
+     * Intended for use from finally blocks.
+     * 
+     * @param closeable the object to close, may be {@code null}
+     */
+    public static void closeQuietly(Closeable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (IOException e) {
+            }
+        }
+    }
+
+    /**
+     * Closes the socket quietly, catching rather than throwing IOException.
+     * Intended for use from finally blocks.
+     * 
+     * @param socket the socket to close, may be {@code null}
+     */
+    public static void closeQuietly(Socket socket) {
+        if (socket != null) {
+            try {
+                socket.close();
+            } catch (IOException e) {
+            }
+        }
+    }
 }



Mime
View raw message