[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8360: patch from Maxim Katcharov: handle trailing spaces correctly (torctl/trunk/java/net/freehaven/tor/control)



Author: nickm
Date: 2006-09-10 18:30:00 -0400 (Sun, 10 Sep 2006)
New Revision: 8360

Modified:
   torctl/trunk/java/net/freehaven/tor/control/Bytes.java
Log:
patch from Maxim Katcharov: handle trailing spaces correctly in splitStr.

Modified: torctl/trunk/java/net/freehaven/tor/control/Bytes.java
===================================================================
--- torctl/trunk/java/net/freehaven/tor/control/Bytes.java	2006-09-09 19:36:51 UTC (rev 8359)
+++ torctl/trunk/java/net/freehaven/tor/control/Bytes.java	2006-09-10 22:30:00 UTC (rev 8360)
@@ -86,11 +86,13 @@
      * along the character in 'split' and writing them into 'lst'
      */
     public static List splitStr(List lst, String str) {
-        if (lst == null)
-            lst = new ArrayList();
-        StringTokenizer st = new StringTokenizer(str);
-        while (st.hasMoreTokens())
-            lst.add(st.nextToken());
+        // split string on spaces, include trailing/leading
+        String[] tokenArray = str.split(" ", -1);
+        if (lst == null) {
+            lst = Arrays.asList( tokenArray );
+        } else {
+            lst.addAll( Arrays.asList( tokenArray ) );
+        }
         return lst;
     }