Java String Split by Space splitWithoutWhitespace(String source, String separator)

Here you can find the source of splitWithoutWhitespace(String source, String separator)

Description

split Without Whitespace

License

Open Source License

Declaration

public static String[] splitWithoutWhitespace(String source, String separator) 

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 String[] splitWithoutWhitespace(String source, String separator) {
        List<String> result = new ArrayList<String>();
        String[] items = source.split(separator);
        for (String s : items) {
            if (!"".equals(s.trim())) {
                result.add(s.trim());//from  w w w.  j  av  a2s  .  c o m
            }
        }

        return result.toArray(new String[result.size()]);
    }
}

Related

  1. splitOnSpace(final String string)
  2. splitOnSpace(String string)
  3. SplitOnWhitespace(String instrData)
  4. splitSpaces(String input)
  5. splitStringOnWhitespace(String text)
  6. whitespaceSplit(final String input)