[dna-commits] DNA SVN: r432 - trunk/dna-common/src/main/java/org/jboss/dna/common/util.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Fri Aug 15 16:53:01 EDT 2008


Author: spagop
Date: 2008-08-15 16:53:01 -0400 (Fri, 15 Aug 2008)
New Revision: 432

Modified:
   trunk/dna-common/src/main/java/org/jboss/dna/common/util/FileUtil.java
Log:
 Utility to convert File} to URL
  

Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/FileUtil.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/FileUtil.java	2008-08-15 20:24:19 UTC (rev 431)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/FileUtil.java	2008-08-15 20:53:01 UTC (rev 432)
@@ -23,6 +23,8 @@
 package org.jboss.dna.common.util;
 
 import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
 
 public class FileUtil {
 
@@ -57,5 +59,20 @@
         // Whether this is a file or empty directory, just delete it ...
         return fileOrDirectory.delete();
     }
+    
+    /**
+     * Utility to convert {@link File} to {@link URL}.
+     * 
+     * @param filePath - the path of the file.
+     * @return the {@link URL} representation of the file.
+     * @throws MalformedURLException 
+     */
+    public static URL convertFileToURL( String filePath ) throws MalformedURLException {
+        if(filePath == null || filePath.equals("")) {
+            throw new IllegalArgumentException("file path is nil");
+        }
+        File file = new File(filePath);
+        return file.toURI().toURL();
+    }
 
 }




More information about the dna-commits mailing list