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);