Java String Split split(String s, String spliter, boolean removeEmptyItem)

Here you can find the source of split(String s, String spliter, boolean removeEmptyItem)

Description

split

License

Open Source License

Declaration

public static String[] split(String s, String spliter, boolean removeEmptyItem) 

Method Source Code

//package com.java2s;
/*/*ww w  . j  a v a  2  s  . c om*/
 * Copyright (C) 2014 The MANO Authors. 
 * All rights reserved. Use is subject to license terms. 
 * 
 * See more http://mano.diosay.com/
 * 
 */

import java.util.ArrayList;

public class Main {
    public static String[] split(String s, String spliter, boolean removeEmptyItem) {
        String[] arr = (s == null) ? new String[0] : s.split(spliter);
        if (removeEmptyItem) {
            ArrayList<String> temp = new ArrayList<>();
            for (int i = 0; i < arr.length; i++) {
                if (!"".equals(arr[i].trim())) {
                    temp.add(arr[i].trim());
                }
            }
            arr = temp.toArray(new String[0]);
        }
        return arr;
    }

    public static String[] split(String s, String spliter) {
        return split(s, spliter, false);
    }
}

Related

  1. split(String s)
  2. split(String s, int c)
  3. split(String s, String at)
  4. split(String s, String s1)
  5. split(String s, String seperator)
  6. split(String s, String splitStr)
  7. split(String s, String splitter)
  8. split(String self)
  9. split(String signature, boolean skipInitialAngleBracket)