Java tutorial
//package com.java2s; /** * Copyright (c) 2013, 2014 Denis Nikiforov. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Denis Nikiforov - initial API and implementation */ public class Main { public static String convertCamelCaseToAllCaps(String qualifiedClassName) { StringBuffer sb = new StringBuffer(); final char[] charArray = qualifiedClassName.toCharArray(); for (int c = 0; c < charArray.length; c++) { char character = charArray[c]; final boolean isEnd = c + 1 == charArray.length; boolean nextIsUpper = !isEnd && Character.isUpperCase(charArray[c + 1]); boolean nextNextIsLower = c + 2 < (charArray.length) && Character.isLowerCase(charArray[c + 2]); sb.append(Character.toUpperCase(character)); if (Character.isLowerCase(character) && nextIsUpper) { sb.append('_'); } else { if (nextIsUpper && nextNextIsLower) { sb.append('_'); } } } return sb.toString(); } }