Split a string into words in Java
Use a Pattern class from the java.util.regex package to split a long string into separate words in Java.
A Pattern is a compiled representation of a regular expression.
String str = "a very long string possibly with line breaks , tab delimiters etc";
Pattern p = Pattern.compile("[,\\s]+");
String[] arr = p.split(str);
Interesting,
you can go to w3 school website for more information on that
Thanks for bringing this up
Comment by web development company — August 11, 2009 @ 5:42 pm