Java String Split by Delimiter split(String s, String delimiter)

Here you can find the source of split(String s, String delimiter)

Description

split

License

Open Source License

Declaration

public static List<String> split(String s, String delimiter) 

Method Source Code

//package com.java2s;
/*//from   w w  w .ja v a2 s .  c o m
 * This file is part of ConfigHub.
 *
 * ConfigHub is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ConfigHub is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.??See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ConfigHub.??If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.*;

public class Main {
    public static List<String> split(String s, String delimiter) {
        List<String> ret = new ArrayList<>();
        if (isBlank(s)) {
            return ret;
        }

        String ss[] = s.split(delimiter);
        for (String ass : ss) {
            if (isBlank(ass)) {
                continue;
            }
            ret.add(ass.trim());
        }

        return ret;
    }

    public static boolean isBlank(String s) {
        if (null == s) {
            return true;
        }

        if ("".equals(s.trim())) {
            return true;
        }

        return false;
    }
}

Related

  1. split(String s, char delimiter)
  2. split(String s, char delimiter)
  3. split(String s, String delim)
  4. split(String s, String delim)
  5. split(String s, String delim)
  6. split(String s, String delimiter)
  7. split(String s, String delimiter)
  8. split(String src, char delim)
  9. split(String src, char delim)