[sword-svn] r108 - trunk/micro/src/org/crosswire/flashcards

Apache apache at www.crosswire.org
Wed Dec 27 16:57:17 MST 2006


Author: 
Date: 2006-12-27 16:57:16 -0700 (Wed, 27 Dec 2006)
New Revision: 108

Modified:
   trunk/micro/src/org/crosswire/flashcards/Properties.java
Log:
Added loadURL method for retrieving properties via web


Modified: trunk/micro/src/org/crosswire/flashcards/Properties.java
===================================================================
--- trunk/micro/src/org/crosswire/flashcards/Properties.java	2006-12-12 06:44:05 UTC (rev 107)
+++ trunk/micro/src/org/crosswire/flashcards/Properties.java	2006-12-27 23:57:16 UTC (rev 108)
@@ -3,6 +3,8 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.Hashtable;
+import javax.microedition.io.StreamConnection;
+import javax.microedition.io.Connector;
 
 /**
  * <p>Title: </p>
@@ -31,8 +33,25 @@
       throw new Exception("File Does Not Exist");
     }
     load(is);
+    is.close();
   }
 
+  public void loadURL(String url) throws Exception {
+    StreamConnection c = null;
+    InputStream is = null;
+    try {
+        c = (StreamConnection)Connector.open(url);
+        is = c.openInputStream();
+        load(is);
+    }
+    finally {
+       if (is != null)
+           is.close();
+       if (c != null)
+           c.close();
+   }
+  }
+
   public void load(InputStream is) {
     String content = getInputStreamContents(is);
     int[] pos = new int[1];
@@ -56,7 +75,6 @@
       String value = line.substring(divider + 1);
       setProperty(key, value);
     }
-
   }
 
   public static String getInputStreamContents(InputStream is) {




More information about the sword-cvs mailing list