Java examples for java.lang:String Camel Case
converts string to camel case, using the specified string delimiter
//package com.java2s; public class Main { /**//from w w w.j a v a 2 s .co m * converts string to camel case, using the specified string delimiter */ public static String camelCase(final String value, final String delim) { // check for null if (value == null || value.isEmpty()) { return ""; } final StringBuilder result = new StringBuilder(value.length()); final String[] parts = value.split(delim); if (parts != null && parts.length > 0) { boolean mustCapitalize = false; for (final String part : parts) { if (part.length() > 1) { if (mustCapitalize) { result.append(part.substring(0, 1).toUpperCase()); result.append(part.substring(1).toLowerCase()); } else { result.append(part); mustCapitalize = true; } } else { result.append(part); } } } return result.toString(); } }