Java String Split by Case splitByCharacterTypeCamelCase(String targetName)

Here you can find the source of splitByCharacterTypeCamelCase(String targetName)

Description

split By Character Type Camel Case

License

Open Source License

Declaration

private static List<String> splitByCharacterTypeCamelCase(String targetName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    private static List<String> splitByCharacterTypeCamelCase(String targetName) {
        List<String> wordsList = new ArrayList<String>();

        StringBuilder word = new StringBuilder();

        for (int i = 0; i < targetName.length(); i++) {
            char c = targetName.charAt(i);

            if (Character.isUpperCase(c) && i > 0) {
                wordsList.add(word.toString());
                word.delete(0, word.length());
                word.append(Character.toLowerCase(c));
            } else {
                word.append(Character.toLowerCase(c));
            }//from  w ww .  ja v  a  2s . c  om
        }

        wordsList.add(word.toString());

        return wordsList;
    }
}

Related

  1. split(String pString, String pSeparator, boolean pIgnoreCase)
  2. splitByCamelCase(String name)
  3. splitCamelCase(final String in)
  4. splitCamelCase(final String s)
  5. splitCamelCase(String src)
  6. splitCamelCase(String string)