How to split a string delimitted by vertical bar(|)

Hi

I would like to split a string delimitted by verticl bar using String.split("|") functionality.When I used split functionality for other delimitters like "-" or ":" or ";" it worked perfectly but if I use vertical bar it is splitting all the individual characters in thet string

Is it because verical bar is having some significance in regular expressions

Can some body please shed light on this

[425 byte] By [satwika] at [2007-10-3 4:04:09]
# 1
StringTokenizer
filestreama at 2007-7-14 22:03:18 > top of Java-index,Java Essentials,Java Programming...
# 2
That's because the String you enter as a parameter is a regular expression. The pipe character ( | ) represents OR so you could say"A | C" meaning A or C. Put a backslash behind the character and it should be treated as a character.myString.split("\|")
souLTowera at 2007-7-14 22:03:18 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks for respondong immediately.I can't use StringTokenizer because It can't handle null strings.Coming to use back slah like you said Mystring.split("\|")is giving compilation error saying that "illegal escape character"
satwika at 2007-7-14 22:03:18 > top of Java-index,Java Essentials,Java Programming...
# 4

> Thanks for respondong immediately.I can't use

> StringTokenizer because It can't handle null

> strings.

>Coming to use back slah like you said

> Mystring.split("\|")is giving compilation error

> saying that "illegal escape character"

You need two of \, so it should be \\|

Kaj

kajbja at 2007-7-14 22:03:18 > top of Java-index,Java Essentials,Java Programming...
# 5
Woh!! it workedThanks again for all of you
satwika at 2007-7-14 22:03:18 > top of Java-index,Java Essentials,Java Programming...