org.apache.commons.text.CaseUtils.toCamelCase() Java Code Examples

How to use toCamelCase() method in org.apache.commons.text.CaseUtils class.

More Java code examples for org.apache.commons.text.CaseUtils Apache Commons Text library.

Java Code Example 1 converts all the delimiter separated words in a String into camelCase with lowercase first letter

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample1 {
    public static void main(String[] args) {
        String inputString = "Testing String";
        boolean isCapitalizeFirstLetter = false;

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: Testing String
Output String: testingString

Java Code Example 2 converts all the delimiter separated words in a String into camelCase with lowercase first letter

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample2 {
    public static void main(String[] args) {
        String inputString = "testing String";
        boolean isCapitalizeFirstLetter = false;

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: testing String
Output String: testingString

Java Code Example 3 converts all the delimiter separated words in a String into camelCase with lowercase first letter

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample3 {
    public static void main(String[] args) {
        String inputString = "testing string";
        boolean isCapitalizeFirstLetter = false;

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: testing string
Output String: testingString

Java Code Example 4 converts all the delimiter separated words in a String into camelCase with uppercase first letter

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample4 {
    public static void main(String[] args) {
        String inputString = "Testing String";
        boolean isCapitalizeFirstLetter = true;

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: Testing String
Output String: TestingString

Java Code Example 5 converts all the delimiter separated words in a String into camelCase with uppercase first letter

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample5 {
    public static void main(String[] args) {
        String inputString = "testing String";
        boolean isCapitalizeFirstLetter = true;

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: testing String
Output String: TestingString

Java Code Example 6 converts all the delimiter separated words in a String into camelCase with uppercase first letter

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample6 {
    public static void main(String[] args) {
        String inputString = "testing string";
        boolean isCapitalizeFirstLetter = true;

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: testing string
Output String: TestingString

Java Code Example 7

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample7 {
    public static void main(String[] args) {
        String inputString = "To.Camel.Case";
        boolean isCapitalizeFirstLetter = false;
        char[] delimiters = new char[]{'.'};

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter, delimiters);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String: To.Camel.Case
Output String: toCamelCase

Java Code Example 8

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample8 {
    public static void main(String[] args) {
        String inputString = " to @ Camel case";
        boolean isCapitalizeFirstLetter = true;
        char[] delimiters = new char[]{'@'};

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter, delimiters);
        
        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String:  to @ Camel case
Output String: ToCamelCase

Java Code Example 9

import org.apache.commons.text.CaseUtils;

public class CaseUtilsToCamelCaseExample9 {
    public static void main(String[] args) {
        String inputString = " @to @ Camel case";
        boolean isCapitalizeFirstLetter = false;
        char[] delimiters = new char[]{'@'};

        String outputString = CaseUtils.toCamelCase(inputString, isCapitalizeFirstLetter, delimiters);

        System.out.println("Input String: " + inputString);
        System.out.println("Output String: " + outputString);
    }
}
Output:

Input String:  @to @ Camel case
Output String: toCamelCase

Convert words in a String into camelCase in Java using Apache Commons Text