Here you can find the source of camelCaseToSeparatorCase(String s, String separator)
static protected String camelCaseToSeparatorCase(String s, String separator)
//package com.java2s; //License from project: LGPL public class Main { static protected String camelCaseToSeparatorCase(String s, String separator) { char[] input = s.toCharArray(); StringBuilder output = new StringBuilder(); for (int i = 0; i < input.length; i++) { char c = input[i]; if (Character.isLowerCase(c) || isSpecialCharacter(c)) { output.append(c);/*from www . j ava 2 s .c om*/ } else { if (i > 0) { if ((previousCharIsLowerCase(input, i) || nextCharIsLowerCase(input, i)) && (!isSpecialCharacter(input[i - 1]) && !isSpecialCharacter(input[i + 1]))) { output.append(separator); } } output.append(Character.toLowerCase(c)); } } String result = output.toString(); return result; } static private boolean isSpecialCharacter(char c) { return !Character.isLetterOrDigit(c); } static private boolean previousCharIsLowerCase(char[] input, int i) { return Character.isLowerCase(input[i - 1]); } static private boolean nextCharIsLowerCase(char[] input, int i) { return i < (input.length - 1) && Character.isLowerCase(input[i + 1]); } }