Java String Camel Case Format toCamelCase(String s)

Here you can find the source of toCamelCase(String s)

Description

to Camel Case

License

Open Source License

Declaration

public static String toCamelCase(String s) 

Method Source Code

//package com.java2s;
/*// ww w .j a  v a2 s .c om
 * Xapp (pronounced Zap!), A automatic gui tool for Java.
 * Copyright (C) 2009 David Webber. All Rights Reserved.
 *
 * The contents of this file may be used under the terms of the GNU Lesser
 * General Public License Version 2.1 or later.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 */

public class Main {
    public static String toCamelCase(String s) {
        String result = "";
        String[] args = s.split("\\s+");
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (i > 0) {
                arg = capitalizeFirst(arg);
            }
            result += arg;
        }
        return result;
    }

    public static String capitalizeFirst(String s) {
        return s.substring(0, 1).toUpperCase() + s.substring(1);
    }
}

Related

  1. toCamelCase(String name)
  2. toCamelCase(String name)
  3. toCamelCase(String original)
  4. toCamelCase(String originalName)
  5. toCamelCase(String origString)
  6. toCamelCase(String s)
  7. toCamelCase(String s)
  8. toCamelCase(String s)
  9. toCamelCase(String s)