jon 00/12/17 13:53:43
Modified: src/java/org/apache/velocity/util StringUtils.java
Log:
moved method to here instead of in Runtime
Revision Changes Path
1.5 +30 -1
jakarta-velocity/src/java/org/apache/velocity/util/StringUtils.java
Index: StringUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/StringUtils.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StringUtils.java 2000/12/11 19:39:01 1.4
+++ StringUtils.java 2000/12/17 21:53:42 1.5
@@ -56,6 +56,8 @@
import java.io.*;
+import java.net.MalformedURLException;
+
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -68,7 +70,7 @@
* string utilities class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: StringUtils.java,v 1.4 2000/12/11 19:39:01 jon Exp $
+ * @version $Id: StringUtils.java,v 1.5 2000/12/17 21:53:42 jon Exp $
*/
public class StringUtils
{
@@ -91,6 +93,33 @@
s[i] = (String) v.elementAt(i);
return s;
+ }
+
+ /**
+ * This was borrowed form xml-fop. Convert a file
+ * name into a string that represents a well-formed
+ * URL.
+ *
+ * d:\path\to\logfile
+ * file://d:/path/to/logfile
+ *
+ * NOTE: this is a total hack-a-roo! This should
+ * be dealt with in the org.apache.log package. Client
+ * packages should not have to mess around making
+ * properly formed URLs when log files are almost
+ * always going to be specified with file paths!
+ */
+ public static String fileToURL(String filename)
+ throws MalformedURLException
+ {
+ File file = new File(filename);
+ String path = file.getAbsolutePath();
+ String fSep = System.getProperty("file.separator");
+
+ if (fSep != null && fSep.length() == 1)
+ path = "file://" + path.replace(fSep.charAt(0), '/');
+
+ return path;
}
public static StringBuffer stringSubstitution(String argStr,