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();
+ }
}
Show replies by date