Java String Camel Case Format toCamelCaseVar(String s)

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

Description

to Camel Case Var

License

Open Source License

Declaration

public static String toCamelCaseVar(String s) 

Method Source Code

//package com.java2s;
/*/*from  ww w.j av  a2s.  c  o m*/
Copyright Alex R.M. Turner 2008
This file is part of Hermes DB
Hermes DB is free software; you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as published by
the Free Software Foundation; version 3 of the License.
    
Hermes DB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the Lesser GNU General Public License
along with Hermes DB if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
This file is released under the LGPL v3.0
*/

public class Main {
    public static String toCamelCaseVar(String s) {
        if (s == null) {
            return null;
        }

        StringBuffer in = new StringBuffer(s);
        while (in.indexOf("_") != -1) {
            int x = in.indexOf("_");
            in.replace(x, x + 2, in.substring(x + 1, x + 2).toUpperCase());
        }

        return in.toString();
    }
}

Related

  1. toCamelCaseCapitalize(String underLineName)
  2. toCamelCaseIdentifier(String formStr)
  3. toCamelCaseIgnoringLastChar(String string, String delimiter, boolean upperFirst)
  4. toCamelCasePresevingExisting(String s)
  5. toCamelCaseSimple(String str)