Implement Data utility to encapsulate resource management
[jpim.git] / src / de / j32 / pimstuff / Main.java
index 733b6f3..6214c7f 100644 (file)
@@ -4,11 +4,8 @@ import java.io.IOException;
 
 import de.j32.pimstuff.conduit.Conduit;
 import de.j32.pimstuff.conduit.ConduitException;
-import de.j32.pimstuff.conduit.Exporter;
-import de.j32.pimstuff.conduit.Importer;
 import de.j32.pimstuff.conduit.Registry;
 import de.j32.pimstuff.data.Addressbook;
-import de.j32.util.Util;
 
 public class Main
 {
@@ -16,30 +13,11 @@ public class Main
     public static void main(String[] args)
     {
         try {
-            Addressbook ab = new Addressbook();
+            Addressbook abook = new Addressbook();
             Conduit conduit = Registry.get("fritzbox");
 
-            Importer i = null;
-            try {
-                i = conduit.importer();
-                i.sendTo(ab);
-                i.close();
-                i = null;
-            }
-            finally {
-                Util.nothrowClose(i);
-            }
-
-            Exporter e = null;
-            try {
-                e = conduit.exporter();
-                ab.sendTo(e);
-                e.close();
-                e = null;
-            }
-            finally {
-                Util.nothrowClose(e);
-            }
+            Data.transfer(conduit, abook);
+            Data.transfer(abook, conduit);
         }
         catch (ConduitException e) {
             e.printStackTrace();