svn commit: r1649971 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1649971 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java

adrianc
Author: adrianc
Date: Tue Jan  6 23:22:56 2015
New Revision: 1649971

URL: http://svn.apache.org/r1649971
Log:
Removed an unused method from UtilURL.java, added some JavaDocs.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java?rev=1649971&r1=1649970&r2=1649971&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java Tue Jan  6 23:22:56 2015
@@ -18,11 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.base.util;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URL;
 
@@ -44,6 +40,16 @@ public class UtilURL {
         return fromResource(contextClass, resourceName);
     }
 
+    /**
+     * Returns a <code>URL</code> instance from a resource name. Returns
+     * <code>null</code> if the resource is not found.
+     * <p>This method uses various ways to locate the resource, and in all
+     * cases it tests to see if the resource exists - so it
+     * is very inefficient.</p>
+     *
+     * @param resourceName
+     * @return
+     */
     public static URL fromResource(String resourceName) {
         return fromResource(resourceName, null);
     }
@@ -55,6 +61,17 @@ public class UtilURL {
             return fromResource(resourceName, contextClass.getClassLoader());
     }
 
+    /**
+     * Returns a <code>URL</code> instance from a resource name. Returns
+     * <code>null</code> if the resource is not found.
+     * <p>This method uses various ways to locate the resource, and in all
+     * cases it tests to see if the resource exists - so it
+     * is very inefficient.</p>
+     *
+     * @param resourceName
+     * @param loader
+     * @return
+     */
     public static URL fromResource(String resourceName, ClassLoader loader) {
         if (loader == null) {
             try {
@@ -148,33 +165,4 @@ public class UtilURL {
         }
         return path;
     }
-
-    public static String readUrlText(URL url) throws IOException {
-        InputStream stream = url.openStream();
-
-        StringBuilder buf = new StringBuilder();
-        BufferedReader in = null;
-        try {
-            in = new BufferedReader(new InputStreamReader(stream));
-
-            String str;
-            while ((str = in.readLine()) != null) {
-                buf.append(str);
-                buf.append(System.getProperty("line.separator"));
-            }
-        } catch (IOException e) {
-            Debug.logError(e, "Error reading text from URL [" + url + "]: " + e.toString(), module);
-            throw e;
-        } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    Debug.logError(e, "Error closing after reading text from URL [" + url + "]: " + e.toString(), module);
-                }
-            }
-        }
-
-        return buf.toString();
-    }
 }