Tuesday, February 25, 2014

"ravikiran@is%good*person", split the string with special charecters.

import java.util.StringTokenizer;


public class StringTokenizerTest {
    public static void main(String[] args) {
       
        String str = "ravikiran@is%good*person";
       
        System.out.println("---- Split by Special chars ------");
        StringTokenizer st2 = new StringTokenizer(str, "@%*");

        while (st2.hasMoreElements()) {
            System.out.println(st2.nextElement());
        }
    }
}

O/p:

---- Split by Special chars ------
ravikiran
is
good
person


No comments:

Post a Comment