Java String Split splitws(String val)

Here you can find the source of splitws(String val)

Description

splitws

License

Open Source License

Declaration

public static List splitws(String val) 

Method Source Code


//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;
    }
}

Related

  1. splitValues(String strValues)
  2. splitValues(String value)
  3. splitVersion(String version)
  4. splitWithoutEscaped(String str, String sep)
  5. splitWS(String s, boolean decode)
  6. stringSplit(String s)
  7. stringSplit(String string, String tokens, boolean trimStrings)
  8. stringSplitter(String string)