Java String to kenizer
Return Delimiters as Tokens
import
java.util.StringTokenizer;
public class
StringTokenizerReturnDelimiterExample
{
public static void main(String[] args)
{
StringTokenizer st = new
StringTokenizer("Java|StringTokenizer|Example 1",
"|", true);
while(st.hasMoreTokens())
System.out.println(st.nextToken("|"));
}
}
Java String To
kenizer Specify Delimiter
import
java.util.StringTokenizer;
public class
StringTokenizerSpecifyDelimiterExample
{
public static void
main(String[] args)
{
StringTokenizer st1 = new
StringTokenizer("Java|StringTokenizer|Example 1", "|");
while(st1.hasMoreTokens())
System.out.println(st1.nextToken());
StringTokenizer st2 = new
StringTokenizer("Java|StringTokenizer|Example 2");
while(st2.hasMoreTokens())
System.out.println(st2.nextToken("|"));
}
}
Java String To
kenizer count tokens
import
java.util.StringTokenizer;
public class
StringTokenizerCountTokensExample
{
public static void
main(String[] args)
{
StringTokenizer st = new StringTokenizer("Java
StringTokenizer count Tokens Example");
while(st.hasMoreTokens())
{
System.out.println("Remaining
Tokens : " + st.countTokens());
System.out.println(st.nextToken());
}
}
}
Java String To
kenizer
import
java.util.StringTokenizer;
public class
JavaStringTokenizerExample
{
public static void
main(String[] args)
{
StringTokenizer st = new
StringTokenizer("Java StringTokenizer Example");
while(st.hasMoreTokens())
System.out.println(st.nextToken());
}
}
Java String To
kenizer return tokens as Objects
import
java.util.StringTokenizer;
public class
StringTokenizerReturnTokensAsObjectsExample
{
public static void
main(String[] args)
{
StringTokenizer st = new
StringTokenizer("Java StringTokenizer Example");
while(st.hasMoreElements())
{
System.out.println(st.nextElement());
}
}
}
No comments:
Post a Comment