Java String Split by Case splitOnUppercase(String input)

Here you can find the source of splitOnUppercase(String input)

Description

split On Uppercase

License

Open Source License

Declaration

public static final String[] splitOnUppercase(String input) 

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 final String[] splitOnUppercase(String input) {
        StringBuilder part = new StringBuilder();
        List<String> parts = new ArrayList<String>();
        for (char c : input.toCharArray()) {
            if (Character.isUpperCase(c)) {
                if (part.length() > 0)
                    parts.add(part.toString());
                part.setLength(0);/*from ww w  .ja v  a2s. c om*/
            }
            part.append(c);
        }
        if (part.length() > 0)
            parts.add(part.toString());
        return parts.toArray(new String[parts.size()]);
    }
}

Related

  1. splitByCharacterTypeCamelCase(String targetName)
  2. splitCamelCase(final String in)
  3. splitCamelCase(final String s)
  4. splitCamelCase(String src)
  5. splitCamelCase(String string)
  6. splitString(String string, Character character, boolean encased)
  7. splitWords(String text, boolean toLowerCase)