Java String Capitalize Full capitalizeFully(String input, String delimiters)

Here you can find the source of capitalizeFully(String input, String delimiters)

Description

This is a re-implementation of the capitalizeFully of Apache commons lang, because it appears not working properly.

License

Apache License

Declaration

public static String capitalizeFully(String input, String delimiters) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  www.jav  a  2  s . c o m
     * This is a re-implementation of the capitalizeFully of Apache commons lang, because it appears not working
     * properly.
     * <p/>
     * Convert a string so that each word is made up of a titlecase character and then a series of lowercase
     * characters. Words are defined as token delimited by one of the character in delimiters or the begining
     * of the string.
     */
    public static String capitalizeFully(String input, String delimiters) {
        if (input == null) {
            return null;
        }

        //input = input.toLowerCase();
        String output = "";
        boolean toUpper = true;
        for (int c = 0; c < input.length(); c++) {
            char ch = input.charAt(c);

            if (delimiters.indexOf(ch) != -1) {
                toUpper = true;
                output += ch;
            } else {
                if (toUpper == true) {
                    output += Character.toUpperCase(ch);
                    toUpper = false;
                } else {
                    output += Character.toLowerCase(ch);
                }
            }
        }
        return output;
    }
}

Related

  1. capitalizeFully(String input)
  2. capitalizeFully(String str)
  3. capitalizeFully(String str)
  4. capitalizeFully(String str)
  5. capitalizeFully(String str)