Author: j16sdiz
Date: 2008-08-15 11:18:28 +0000 (Fri, 15 Aug 2008)
New Revision: 21896

Modified:
   trunk/freenet/src/freenet/io/NetworkInterface.java
   trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
   trunk/freenet/src/freenet/support/FileLoggerHook.java
   trunk/freenet/src/freenet/support/io/Closer.java
   trunk/freenet/src/freenet/support/io/RandomAccessThing.java
Log:
use java.io.Closeable

Modified: trunk/freenet/src/freenet/io/NetworkInterface.java
===================================================================
--- trunk/freenet/src/freenet/io/NetworkInterface.java  2008-08-15 11:17:58 UTC 
(rev 21895)
+++ trunk/freenet/src/freenet/io/NetworkInterface.java  2008-08-15 11:18:28 UTC 
(rev 21896)
@@ -16,6 +16,7 @@

 package freenet.io;

+import java.io.Closeable;
 import java.io.IOException;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -40,7 +41,7 @@
  * @author David Roden <droden at gmail.com>
  * @version $Id$
  */
-public class NetworkInterface {
+public class NetworkInterface implements Closeable {

         public static final String DEFAULT_BIND_TO = 
"127.0.0.1,0:0:0:0:0:0:0:1";


Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java        
2008-08-15 11:17:58 UTC (rev 21895)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java        
2008-08-15 11:18:28 UTC (rev 21896)
@@ -1,6 +1,7 @@
 package freenet.node.fcp;

 import java.io.BufferedOutputStream;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -16,7 +17,7 @@
 import freenet.support.io.Closer;
 import freenet.support.io.FileUtil;

-public class FCPConnectionHandler {
+public class FCPConnectionHandler implements Closeable {
        private static final class DirectoryAccess {
                final boolean canWrite;
                final boolean canRead;

Modified: trunk/freenet/src/freenet/support/FileLoggerHook.java
===================================================================
--- trunk/freenet/src/freenet/support/FileLoggerHook.java       2008-08-15 
11:17:58 UTC (rev 21895)
+++ trunk/freenet/src/freenet/support/FileLoggerHook.java       2008-08-15 
11:18:28 UTC (rev 21896)
@@ -1,6 +1,7 @@
 package freenet.support;

 import java.io.BufferedOutputStream;
+import java.io.Closeable;
 import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -32,7 +33,7 @@
  * 
  * @author oskar
  */
-public class FileLoggerHook extends LoggerHook {
+public class FileLoggerHook extends LoggerHook implements Closeable {

        /** Verbosity types */
        public static final int DATE = 1,

Modified: trunk/freenet/src/freenet/support/io/Closer.java
===================================================================
--- trunk/freenet/src/freenet/support/io/Closer.java    2008-08-15 11:17:58 UTC 
(rev 21895)
+++ trunk/freenet/src/freenet/support/io/Closer.java    2008-08-15 11:18:28 UTC 
(rev 21896)
@@ -18,12 +18,8 @@

 package freenet.support.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.util.jar.JarFile;
 import java.util.zip.ZipFile;

 /**
@@ -36,77 +32,16 @@
  * @version $Id$
  */
 public class Closer {
-
        /**
-        * Closes the given output stream.
+        * Closes the given stream.
         * 
         * @param outputStream
         *            The output stream to close
         */
-       public static void close(OutputStream outputStream) {
-               if (outputStream != null) {
+       public static void close(Closeable closable) {
+               if (closable != null) {
                        try {
-                               outputStream.close();
-                       } catch (IOException ioe1) {
-                       }
-               }
-       }
-
-       /**
-        * Closes the given input stream.
-        * 
-        * @param inputStream
-        *            The input stream to close
-        */
-       public static void close(InputStream inputStream) {
-               if (inputStream != null) {
-                       try {
-                               inputStream.close();
-                       } catch (IOException ioe1) {
-                       }
-               }
-       }
-
-       /**
-        * Closes the given writer.
-        * 
-        * @param writer
-        *            The writer to close
-        */
-       public static void close(Writer writer) {
-               if (writer != null) {
-                       try {
-                               writer.close();
-                       } catch (IOException ioe1) {
-                       }
-               }
-       }
-
-       /**
-        * Closes the given reader.
-        * 
-        * @param reader
-        *            The reader to close
-        */
-       public static void close(Reader reader) {
-               if (reader != null) {
-                       try {
-                               reader.close();
-                       } catch (IOException ioe1) {
-                       }
-               }
-       }
-
-       /**
-        * Closes the given jar file.
-        * 
-        * @param jarFile
-        *            The jar file to close
-        */
-       public static void close(JarFile jarFile) {
-               if (jarFile != null) {
-                       try {
-                               jarFile.close();
+                               closable.close();
                        } catch (IOException e) {
                        }
                }

Modified: trunk/freenet/src/freenet/support/io/RandomAccessThing.java
===================================================================
--- trunk/freenet/src/freenet/support/io/RandomAccessThing.java 2008-08-15 
11:17:58 UTC (rev 21895)
+++ trunk/freenet/src/freenet/support/io/RandomAccessThing.java 2008-08-15 
11:18:28 UTC (rev 21896)
@@ -3,13 +3,14 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.support.io;

+import java.io.Closeable;
 import java.io.IOException;

 /**
  * Trivial random access file base interface.
  * @author toad
  */
-public interface RandomAccessThing {
+public interface RandomAccessThing extends Closeable {

        public long size() throws IOException;



Reply via email to