Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

StringTokenizer not working with double pipes

843789Mar 25 2009 — edited Mar 25 2009
Hi,

I'm trying to use the StringTokenizer to split a string into peaces on dual pipes ||
The string looks like this:
"abcd||efgh|ijklm||nopqr"
This is the result i want
 {abcd, efgh|ijklm, nopqr} 
I'm have used the following code:
tokenizer = new StringTokenizer("abcd||efgh|ijklm||nopqr", "\\|{2}");
tokenizer = new StringTokenizer("abcd||efgh|ijklm||nopqr", "\\|\\|");
tokenizer = new StringTokenizer("abcd||efgh|ijklm||nopqr", "\\||");
tokenizer = new StringTokenizer("abcd||efgh|ijklm||nopqr", "||");
The end result is almost always that the string is being split on a single pipe
{abcd, efgh, ijklm, nopqr}
How can i use the string tokenizer to split on the dual pipes.
Note: i can't alter the string content to use other delimiters
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2009
Added on Mar 25 2009
15 comments
216 views