Here you can find the source of camelcaseToUppercase(String camelCase)
Parameter | Description |
---|---|
camelCase | Name in camel-case notation. |
public static String camelcaseToUppercase(String camelCase)
//package com.java2s; /**//www .j ava2 s . co m * Copyright 2011 The Open Source Research Group, * University of Erlangen-N?rnberg * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Converts a name that's given in camel-case into upper-case, inserting * underscores before upper-case letters. * * @param camelCase * Name in camel-case notation. * @return Name in upper-case notation. */ public static String camelcaseToUppercase(String camelCase) { int n = camelCase.length(); StringBuilder upperCase = new StringBuilder(n * 4 / 3); for (int i = 0; i < n; ++i) { char ch = camelCase.charAt(i); if (Character.isUpperCase(ch)) { upperCase.append('_'); upperCase.append(ch); } else { upperCase.append(Character.toUpperCase(ch)); } } return upperCase.toString(); } }