You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2008/04/11 18:31:19 UTC

svn commit: r647216 - /commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java

Author: sebb
Date: Fri Apr 11 09:31:08 2008
New Revision: 647216

URL: http://svn.apache.org/viewvc?rev=647216&view=rev
Log:
Add String split() method (needed for VMS code)

Modified:
    commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java

Modified: commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java?rev=647216&r1=647215&r2=647216&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java (original)
+++ commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java Fri Apr 11 09:31:08 2008
@@ -19,7 +19,10 @@
 package org.apache.commons.exec.util;
 
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 /**
  * Supplement of commons-lang, the stringSubstitution() was in a simpler
@@ -127,4 +130,19 @@
 
       return argBuf;
   }
-}
+  
+  /**
+   * Split a string into an array of strings
+   * @param input what to split
+   * @param splitChar what to split on
+   * @return the array of strings
+   */
+  public static String[] split(String input, String splitChar){
+      StringTokenizer tokens = new StringTokenizer(input, splitChar);
+      List strList=new ArrayList();
+      while (tokens.hasMoreTokens()) {
+          strList.add(tokens.nextToken());
+      }
+     return (String[])strList.toArray(new String[0]);
+  }
+}
\ No newline at end of file