String input = "Hello, world!"; String output = StringUtils.replace(input, ",", "."); System.out.println(output); // Output: "Hello. world!"
String input = "The quick brown fox jumps over the lazy dog."; String output = StringUtils.replace(input, "fox", "cat"); System.out.println(output); // Output: "The quick brown cat jumps over the lazy dog."Overall, the StringUtils class is a helpful utility for working with strings in Java. To use it, you need to include the Apache Commons Lang library in your project's dependencies.