When you pass a second (String) argument to StringTokenizer, the characters in the String are considered individually, not together. Meaning it will not look for the
pattern "==>" but rather for an individual '=' or '>'. Having two of the same character in the String is redundant, but not an error. If what you really want is to find the pattern "==>" but not lone '=' and '>' chars, use the indexOf() method in String:
<code><pre>
int pos = val.indexOf("===>");
if (pos < 0) {<br /> System.out.println("Not found");<br /> }<br /> else {<br /> System.out.println("Before: " + val.substring(0, pos));<br /> System.out.println("After: " + val.substring(pos + 3));<br /> }<br /> </pre></code><br /> To get more of the behavior of StringBuffer, you may want to construct a loop that will look for successive occurrences of the "==>" substring.