0 votes
1 view
in Java by (10.2k points)

I'd like to write a method that converts CamelCase into a human-readable name.

Here's the test case:

public void testSplitCamelCase() {

    assertEquals("lowercase", splitCamelCase("lowercase"));

    assertEquals("Class", splitCamelCase("Class"));

    assertEquals("My Class", splitCamelCase("MyClass"));

    assertEquals("HTML", splitCamelCase("HTML"));

    assertEquals("PDF Loader", splitCamelCase("PDFLoader"));

    assertEquals("A String", splitCamelCase("AString"));

    assertEquals("Simple XML Parser", splitCamelCase("SimpleXMLParser"));

    assertEquals("GL 11 Version", splitCamelCase("GL11Version"));

}

1 Answer

0 votes
by (46.1k points)

You can do it using org.apache.commons.lang.StringUtils

StringUtils.join(

     StringUtils.splitByCharacterTypeCamelCase("ExampleTest"),

     ' '

);

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...