SplitTest.java Illustrates parsing a string with a String.split /** Prints the tokens resulting from treating the first * command-line argument as the string to be tokenized * and the second as the delimiter set. Uses * String.split instead of StringTokenizer. */ public class SplitTest { public static void main(String[] args) { if (args.length == 2) { String input = args[0], delimiters = args[1]; String[] tokens = args[0].split(delimiters); for(int i=0; i<tokens.length; i++)="" {="" string="" token="tokens[i];" if="" (token.length()="" !="0)" system.out.println(token);="" }="" else="" system.out.println="" ("usage:="" java="" splittest="" delimeters");="" <="" pre="">
SplitTest.java Illustrates parsing a string with a String.split
Permanent link to this article: http://bangla.sitestree.com/splittest-java-illustrates-parsing-a-string-with-a-string-split/