Here you can find the source of toCamelCase(String s)
Parameter | Description |
---|---|
s | String to turn into camelCase |
private static String toCamelCase(String s)
//package com.java2s; /* /*from w w w . ja va 2 s .c o m*/ * Copyright (c) Nmote d.o.o. 2003. All rights reserved. * Unathorized use of this file is prohibited by law. * See LICENSE.txt for licensing information. */ public class Main { /** * For a given string, transform it in such a way that every * underscore is removed, and the character following the * underscore gets turned into uppercase. * * @param s String to turn into camelCase */ private static String toCamelCase(String s) { boolean upNext = false; int size = s.length(); StringBuffer result = new StringBuffer(size); for (int i = 0; i < size; ++i) { char c = s.charAt(i); if (c == '_') { upNext = true; } else { if (upNext) { c = Character.toUpperCase(c); upNext = false; } result.append(c); } } return result.toString(); } }