{"id":9995,"date":"2014-05-28T15:27:05","date_gmt":"2014-05-28T12:27:05","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=9995"},"modified":"2021-04-07T14:14:41","modified_gmt":"2021-04-07T11:14:41","slug":"java-stringtokenizer-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/","title":{"rendered":"Java StringTokenizer Example"},"content":{"rendered":"<p>StringTokenizer<a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html\"> class<\/a> in Java is a class from <code>java.util<\/code> package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer class, as well as some of its basic operations.<\/p>\n<p>The JDK version we use to compile the source code in this example is <a href=\"https:\/\/jdk.java.net\/java-se-ri\/13\" target=\"_blank\" rel=\"noreferrer noopener\">OpenJDK 13<\/a> and the IDE we use is <a href=\"https:\/\/www.eclipse.org\/downloads\/\" target=\"_blank\" rel=\"noreferrer noopener\">Eclipse IDE 2020-03<\/a>.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-1-syntax-of-the-constructors\">1. Syntax of the constructors<\/h2>\n<p><a rel=\"noreferrer noopener\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html\" target=\"_blank\">StringTokenizer<\/a> provides three constructors listed in the table below. All of them construct a string tokenizer for the specified string. But the string tokenizer behaves in different ways based on the parameters provided to the constructor. Depending on our application, we can choose one of them.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<thead>\n<tr>\n<th>Constructor<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>StringTokenizer(<a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/String.html\">String<\/a>&nbsp;str)<\/td>\n<td>The default delimiters will be used and delimiter characters will not be returned as tokens. The default delimiter set includes:&nbsp;<code>\"&nbsp;\\t\\n\\r\\f\"<\/code> (the space character, the tab character, the newline character, the carriage-return character, and the form-feed character).<\/td>\n<\/tr>\n<tr>\n<td>StringTokenizer(<a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/String.html\">String<\/a>&nbsp;str, <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/String.html\">String<\/a>&nbsp;delim)<\/td>\n<td>Custom delimiters can be specified by providing the&nbsp;<code>delim<\/code>&nbsp;parameter. Delimiter characters will not be returned as tokens. Note that it is valid to set <code>delim<\/code> as null when constructing a tokenizaer. But invoking other methods on the tokenizer&nbsp;constructed may result in a&nbsp;NullPointerException.<\/td>\n<\/tr>\n<tr>\n<td>StringTokenizer(<a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/String.html\">String<\/a>&nbsp;str, <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/String.html\">String<\/a>&nbsp;delim, boolean&nbsp;returnDelims)<\/td>\n<td>Custom delimiters can be specified by providing the&nbsp;<code>delim<\/code>&nbsp;parameter. If the&nbsp;<code>returnDelims<\/code>&nbsp;flag is&nbsp;<code>true<\/code>, then the delimiter characters are also returned as tokens. Each delimiter is returned as a string of length one. Otherwise, the delimiter characters are skipped and will not be returned as tokens. Note that it is valid to set <code>delim<\/code> as null when constructing a tokenizer. But invoking other methods on the tokenizer&nbsp;constructed may result in a&nbsp;NullPointerException.<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table. 1. StringTokenizer Constructors<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-2-methods-of-stringtokenizer\">2. Methods of StringTokenizer<\/h2>\n<p>There are six public methods defined in <a rel=\"noreferrer noopener\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html\" target=\"_blank\">StringTokenizer<\/a> class as shown in the table below:<\/p>\n<figure class=\"wp-block-table aligncenter is-style-stripes\">\n<table>\n<thead>\n<tr>\n<th>Method<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html#countTokens()\">countTokens<\/a><\/strong>()<\/td>\n<td>Counts the number of tokens the tokenizer has.<\/td>\n<\/tr>\n<tr>\n<td><strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html#hasMoreElements()\">hasMoreElements<\/a><\/strong>()<\/td>\n<td>Same as the&nbsp;<code>hasMoreTokens<\/code>&nbsp;method.<\/td>\n<\/tr>\n<tr>\n<td><strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html#hasMoreTokens()\">hasMoreTokens<\/a><\/strong>()<\/td>\n<td>Returns true if there are more tokens available from this tokenizer&#8217;s string; otherwise returns false.<\/td>\n<\/tr>\n<tr>\n<td><strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html#nextElement()\">nextElement<\/a><\/strong>()<\/td>\n<td>Same as the&nbsp;<code>nextToken<\/code>&nbsp;method, but returns&nbsp;<code>Object<\/code>&nbsp;rather than&nbsp;<code>String<\/code>.<\/td>\n<\/tr>\n<tr>\n<td><strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html#nextToken()\">nextToken<\/a><\/strong>()<\/td>\n<td>Returns the next token from this tokenizer.<\/td>\n<\/tr>\n<tr>\n<td><strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/StringTokenizer.html#nextToken(java.lang.String)\">nextToken<\/a><\/strong>(<a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/String.html\">String<\/a>&nbsp;delim)<\/td>\n<td>Returns the next token by using the delimiter specified.<\/td>\n<\/tr>\n<\/tbody>\n<\/table><figcaption>Table. 2. StringTokenizer Public Methods<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-3-example-of-stringtokenizer-in-java\">3. Example of StringTokenizer in Java<\/h2>\n<p>Let&#8217;s see how to use a StringTokenizer to break a string into tokens in the example below.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"wp-block-codemirror-blocks-code-block code-block\">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;file&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;StringTokenizerExample.java&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}\">import java.util.StringTokenizer;\n\npublic class StringTokenizerExample {\n    \/**\n     * @param args\n     *\/\n    public static void main(String[] args) {\n        String string1 = &quot;It is cool to be a Java code geek!&quot;;\n        System.out.printf(&quot;1. Breaks \\&quot;%s\\&quot; by space\\n&quot;, string1);\n\n        \/\/ constructs a string tokenizer with default delimiters\n        StringTokenizer tokenizer = new StringTokenizer(string1);\n        \/\/ loop in order to take all tokens\n        while (tokenizer.hasMoreTokens()) {\n            \/\/ returns a string\n            System.out.println(tokenizer.nextToken());\n        }\n\n        String string2 = &quot;Java,C++,Basic,Python,Perl&quot;;\n        System.out.printf(&quot;2. Breaks \\&quot;%s\\&quot; by comma\\n&quot;, string2);\n        tokenizer = new StringTokenizer(string2, &quot;,&quot;);\n        System.out.println(&quot;The stokenizer includes &quot; + tokenizer.countTokens() + &quot; tokens.&quot;);\n        while (tokenizer.hasMoreElements()) {\n            \/\/ returns an object\n            Object element = (String) tokenizer.nextElement();\n            System.out.println(element.toString());\n        }\n        \n        System.out.printf(&quot;3. Breaks \\&quot;%s\\&quot; by comma with delimiter returned\\n&quot;, string2);\n        tokenizer = new StringTokenizer(string2, &quot;,&quot;, true);\n        System.out.println(&quot;The stokenizer includes &quot; + tokenizer.countTokens() + &quot; tokens.&quot;);\n        while (tokenizer.hasMoreElements()) {\n            \/\/ returns an object\n            Object element = (String) tokenizer.nextElement();\n            System.out.println(element.toString());\n        }\n    }\n}<\/pre>\n<\/div>\n<p>Run the example code above and you can see the output as below:<\/p>\n<pre class=\"brush:bash\">1. Breaks \"It is cool to be a Java code geek!\" by space\nIt\nis\ncool\nto\nbe\na\nJava\ncode\ngeek!\n2. Breaks \"Java,C++,Basic,Python,Perl\" by comma\nThe stokenizer includes 5 tokens.\nJava\nC++\nBasic\nPython\nPerl\n3. Breaks \"Java,C++,Basic,Python,Perl\" by comma with delimiter returned\nThe stokenizer includes 9 tokens.\nJava\n,\nC++\n,\nBasic\n,\nPython\n,\nPerl\n<\/pre>\n<p>As you can see in the code above, we create three instances of <code>StringTokenizer<\/code> by using different constructors. In the first one, we use the default space delimiter, while in the second and the third one we choose the comma as the delimiter. In order to return all the tokens, we use a while loop where <code>hasMoreTokens()<\/code> or <code>hasMoreElements()<\/code> method is called which indicates whether there are available tokens. In addition, two operations exist (<code>nextToken()<\/code> and <code>nextElement()<\/code>) in order to return the value of the next token. The difference between them is that <code>nextElement()<\/code> method returns an <code>Object<\/code> instead of a <code>String<\/code>. Finally, <code>countTokens()<\/code> method returns the number of the tokens the tokenizer has. In the third tokenizer, we set the <code>returnDelims<\/code> flag to <em>true<\/em> to let it return the delimiter as token together with other tokens.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-4-stringtokenizer-vs-string-split\">4. StringTokenizer vs String.split()<\/h2>\n<p>StringTokenizer&nbsp;was introduced since JDK 1.0.  It is retained as a legacy class and mainly for compatibility reasons. So we&#8217;d better not to use it in our new code. Instead, the split method of String class introduced since JDK 1.4 provides similar functionality which is recommended. Also, for complex use cases, classes from <code>java.util.regex<\/code> package can be another option. <\/p>\n<p>In the example below, we use String.split() method to break the same strings into tokens as we&#8217;ve done with StringTokenizer before.<\/p>\n<div class=\"wp-block-codemirror-blocks-code-block code-block\">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;file&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;StringSplitExample.java&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}\">public class StringSplitExample {\n    \/**\n     * @param args\n     *\/\n    public static void main(String[] args) {\n        \/\/ split by the space character\n        String string1 = &quot;It is cool to be a Java code geek!&quot;;\n        System.out.printf(&quot;1. Splits \\&quot;%s\\&quot; by space\\n&quot;, string1);\n        String[] result = string1.split(&quot;\\\\s&quot;);\n        for (int i = 0; i &lt; result.length; i++) {\n            System.out.println(result[i]);\n        }\n\n        \/\/ split by comma &quot;,&quot;\n        String string2 = &quot;Java,C++,Basic,Python,Perl&quot;;\n        System.out.printf(&quot;2. Splits \\&quot;%s\\&quot; by comma\\n&quot;, string2);\n        result = string2.split(&quot;,&quot;);\n        for (int i = 0; i &lt; result.length; i++) {\n            System.out.println(result[i]);\n        }\n    }\n}<\/pre>\n<\/div>\n<p>Run the example code above and you can see the output as below:<\/p>\n<pre class=\"brush:bash\">1. Splits \"It is cool to be a Java code geek!\" by space\nIt\nis\ncool\nto\nbe\na\nJava\ncode\ngeek!\n2. Splits \"Java,C++,Basic,Python,Perl\" by comma\nJava\nC++\nBasic\nPython\nPerl\n<\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-5-download-the-source-code\">5. Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/java-stringtokenizer-example.zip\"><strong>Java StringTokenizer Example<\/strong><\/a><\/div>\n<p><strong>Last updated on Jun 01st, 2020<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer class, as well as some of its basic operations. The JDK version we use to compile the source code in this example is OpenJDK 13 and the IDE &hellip;<\/p>\n","protected":false},"author":11,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[],"class_list":["post-9995","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stringtokenizer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java StringTokenizer Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java StringTokenizer Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-28T12:27:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-07T11:14:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Katerina Zamani\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Katerina Zamani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\"},\"author\":{\"name\":\"Katerina Zamani\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673\"},\"headline\":\"Java StringTokenizer Example\",\"datePublished\":\"2014-05-28T12:27:05+00:00\",\"dateModified\":\"2021-04-07T11:14:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\"},\"wordCount\":677,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"articleSection\":[\"StringTokenizer\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\",\"name\":\"Java StringTokenizer Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2014-05-28T12:27:05+00:00\",\"dateModified\":\"2021-04-07T11:14:41+00:00\",\"description\":\"StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"util\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/util\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"StringTokenizer\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/util\/stringtokenizer\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Java StringTokenizer Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673\",\"name\":\"Katerina Zamani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg\",\"caption\":\"Katerina Zamani\"},\"description\":\"Katerina has graduated from the Department of Informatics and Telecommunications in National and Kapodistrian University of Athens (NKUA) and she attends MSc courses in Advanced Information Systems at the same department. Currently, her main academic interests focus on web applications, mobile development, software engineering, databases and telecommunications.\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/katerina-zamani\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java StringTokenizer Example - Java Code Geeks","description":"StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/","og_locale":"en_US","og_type":"article","og_title":"Java StringTokenizer Example - Java Code Geeks","og_description":"StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer","og_url":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-05-28T12:27:05+00:00","article_modified_time":"2021-04-07T11:14:41+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Katerina Zamani","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Katerina Zamani","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/"},"author":{"name":"Katerina Zamani","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673"},"headline":"Java StringTokenizer Example","datePublished":"2014-05-28T12:27:05+00:00","dateModified":"2021-04-07T11:14:41+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/"},"wordCount":677,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","articleSection":["StringTokenizer"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/","name":"Java StringTokenizer Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2014-05-28T12:27:05+00:00","dateModified":"2021-04-07T11:14:41+00:00","description":"StringTokenizer class in Java is a class from java.util package. It allows us to break a string into tokens. Here, we show the use of String Tokenizer","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-stringtokenizer-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"util","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/util\/"},{"@type":"ListItem","position":5,"name":"StringTokenizer","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/util\/stringtokenizer\/"},{"@type":"ListItem","position":6,"name":"Java StringTokenizer Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673","name":"Katerina Zamani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg","caption":"Katerina Zamani"},"description":"Katerina has graduated from the Department of Informatics and Telecommunications in National and Kapodistrian University of Athens (NKUA) and she attends MSc courses in Advanced Information Systems at the same department. Currently, her main academic interests focus on web applications, mobile development, software engineering, databases and telecommunications.","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/katerina-zamani\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/9995","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=9995"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/9995\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=9995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=9995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=9995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}