Java examples for Language Basics:String
String split by space using regular expression
public class Main { private String jaText = "this is a test "; public Main() { String[] fields = jaText.split("\\s", 3); for (String field : fields) { System.out.printf("Split: %s\n", field); }/*from w ww. j a va2s. co m*/ } }