[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)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r8360: patch from Maxim Katcharov: handle trailing spaces correctly (torctl/trunk/java/net/freehaven/tor/control)
- From: nickm@xxxxxxxx
- Date: Sun, 10 Sep 2006 18:30:01 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 10 Sep 2006 18:30:09 -0400
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
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;
}