Regarding scanner class
<p>I am currently using StringTokennizer class to split a String into different token as by defined delimiter..</p>

<pre><code>public class App {  
    public static void main(String[] args) {  

        String str = "This is String , split by StringTokenizer, created by Neera";  
        StringTokenizer st = new StringTokenizer(str);  


        System.out.println("---- Split by comma ',' ------");  
        StringTokenizer st2 = new StringTokenizer(str, ",");  

        while (st2.hasMoreElements()) {  
            System.out.println(st2.nextElement());  
        }  
    }  
}  
</code></pre>

<p>My query is that can same thing can also be achieved through scanner class also ...!! Is it the right approach to use the scanner class since I was reading The Scanner class allows you to tokenize data from within a loop, which allows you to stop whenever you want to... I have tried the following thing, but it doesn't work ...please advise me ..!!!</p>

<pre><code>public class App1 {  

    public static void main(String[] args)    
    {  
        Scanner scanner =  new Scanner("This is String , split by StringTokenizer, created by Neera").useDelimiter(", ");    

        while (scanner.hasNextLine()) { 
            System.out.println(scanner.nextLine());
        }
    }
}
</code></pre>
