Java String Split by Case splitByCamelCase(String name)

Here you can find the source of splitByCamelCase(String name)

Description

split By Camel Case

License

Open Source License

Declaration

public static String[] splitByCamelCase(String name) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static String[] splitByCamelCase(String name) {
        List<String> parts = new ArrayList<String>();
        StringBuilder b = new StringBuilder();
        for (int i = 0; i < name.length(); i++) {
            if (i > 0 && Character.isUpperCase(name.charAt(i))) {
                parts.add(b.toString());
                b = new StringBuilder();
            }/*from w  w w  . j av a  2  s. c o  m*/
            b.append(Character.toLowerCase(name.charAt(i)));
        }
        parts.add(b.toString());
        return parts.toArray(new String[] {});
    }
}

Related

  1. split(String pString, String pSeparator, boolean pIgnoreCase)
  2. splitByCharacterTypeCamelCase(String targetName)
  3. splitCamelCase(final String in)
  4. splitCamelCase(final String s)
  5. splitCamelCase(String src)