Java String Camel Case Format toCamelCase(String text, boolean capFirstLetter)

Here you can find the source of toCamelCase(String text, boolean capFirstLetter)

Description

to Camel Case

License

Open Source License

Declaration

public static String toCamelCase(String text, boolean capFirstLetter) 

Method Source Code

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

public class Main {
    public static String toCamelCase(String text, boolean capFirstLetter) {
        String[] parts = text.split("[_]");
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < parts.length; i++) {
            String lc = parts[i].toLowerCase();
            if (i > 0 || capFirstLetter) {
                buf.append(Character.toUpperCase(lc.charAt(0)));
                buf.append(lc.substring(1));
            } else {
                buf.append(lc);//w  ww  .  ja  va  2  s. co m
            }
        }
        return buf.toString();
    }
}

Related

  1. toCamelCase(String string)
  2. toCamelCase(String stringValue, String delimiter)
  3. toCamelCase(String text)
  4. toCamelCase(String text)
  5. toCamelCase(String text)
  6. toCamelCase(String value)
  7. toCamelCase(String value)
  8. toCamelCase(String value)
  9. toCamelCase(String value)