harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r452720 - /incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
Date Wed, 04 Oct 2006 04:23:52 GMT
Author: smishura
Date: Tue Oct  3 21:23:52 2006
New Revision: 452720

URL: http://svn.apache.org/viewvc?view=rev&rev=452720
Log:
Add method getAbsoluteResourcePath()

Modified:
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java

Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java?view=diff&rev=452720&r1=452719&r2=452720
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
Tue Oct  3 21:23:52 2006
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.net.URL;
 
 import tests.support.Support_Configuration;
@@ -149,5 +150,25 @@
         }
         
         return is;
+    }
+    
+    /**
+     * Util method to get absolute path to resource file
+     * 
+     * @param name - name of resource file
+     * @return - path to resource
+     */
+    public static String getAbsoluteResourcePath(String name) {
+
+        URL url = ClassLoader.getSystemClassLoader().getResource(name);
+        if (url == null) {
+            throw new RuntimeException("Failed to load resource: " + name);
+        }
+
+        try {
+            return new File(url.toURI()).getAbsolutePath();
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Failed to load resource: " + name);
+        }
     }
 }



Mime
View raw message