Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use StringUtil.wordsToCamelCase() API.
package com.bethecoder.tutorials.jodd.utils; import jodd.util.StringUtil; public class StringWords2CamelTest { /** * @param args */ public static void main(String[] args) { String str = "This is a test message"; System.out.println(StringUtil.wordsToCamelCase(str)); System.out.println(StringUtil.wordsToCamelCase(str, ' ')); str = "one:two:three:four"; System.out.println(StringUtil.wordsToCamelCase(str, ':')); str = "aaa-bbbb-ccc-ddd-eeeee"; System.out.println(StringUtil.wordsToCamelCase(str, '-')); } }
ThisIsATestMessage ThisIsATestMessage oneTwoThreeFour aaaBbbbCccDddEeeee