Here you can find the source of splitws(String val)
public static List splitws(String val)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List splitws(String val) { List toks = new ArrayList<String>(16); int len = val.length(); while (len > 0 && val.charAt(len - 1) <= ' ') --len;//from w ww . j a v a 2 s . c om int x = 0; while (x < len && val.charAt(x) <= ' ') ++x; for (int i = x; i < len; ++i) { if (val.charAt(i) > ' ') continue; toks.add(val.substring(x, i)); x = i + 1; while (x < len && val.charAt(x) <= ' ') ++x; i = x; } if (x <= len) toks.add(val.substring(x, len)); if (toks.size() == 0) toks.add(""); return toks; } }