Sunday, 7 December 2014

Java : Collection Framework : StringTokenizer (NextToken Param)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=4KLUzs3OdY4&list=UUhwKlOVR041tngjerWxVccw

StringTokenizerExample.java
import java.util.StringTokenizer;

/*
 * Example of nextToken(String delim)
 */
public class StringTokenizerExample
{

    public static void main(String[] args)
    {
        String strValue = "Peter&is&playing&football";
        String delimter = "&";

        StringTokenizer stringTokenizer = new StringTokenizer(strValue);
    
        int i = 1;

        /*
         * Tests if there are more tokens available from this tokenizer's
         * string. If this method returns true, then a subsequent call to
         * nextToken with no argument will successfully return a token.
         */

        while (stringTokenizer.hasMoreTokens())
        {
            /*
             * Returns the next token in this string tokenizer's string.
             */
            String token = stringTokenizer.nextToken(delimter);
            System.out.println("Token " + i + " : " + token);
            ++i;
        }

    }
}

Output
Token 1 : Peter
Token 2 : is
Token 3 : playing
Token 4 : football
To Download StringTokenizerDemoNexttokenParam Project Click the below link

https://sites.google.com/site/javaee4321/java-collections/StringTokenizerDemoNexttokenParam.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge