Code example for StringTokenizer

Methods: countTokensnextElement

0
	 *        java.lang.String, boolean) 
	 */ 
	public void test_ConstructorLjava_lang_StringLjava_lang_StringZ() { 
		// Test for method java.util.StringTokenizer(java.lang.String, 
		// java.lang.String, boolean) 
		StringTokenizer st = new StringTokenizer("This:is:a:test:String", ":",
				true); 
		st.nextElement();
		assertTrue("Created incorrect tokenizer", st.countTokens() == 8
				&& (st.nextElement().equals(":")));
	} 
 
	/** 
	 * @tests java.util.StringTokenizer#countTokens() 
	 */ 
	public void test_countTokens() { 
		// Test for method int java.util.StringTokenizer.countTokens() 
		StringTokenizer st = new StringTokenizer("This is a test String");
 
		assertEquals("Incorrect token count returned", 5, st.countTokens());
Contextual code suggestions in your IDE  Get Codota for Java