String str = "example.com/index.html"; String result = StringUtils.substringBeforeLast(str, "/"); System.out.println(result); // output: example.com
String filename = "example.pdf"; String extension = StringUtils.substringAfterLast(filename, "."); System.out.println(extension); // output: pdfIn this case, we pass the string `filename` and the separator "." to the `substringAfterLast` method. The method then returns the substring "pdf", which represents the file extension. The `substringBeforeLast` method is part of the `org.apache.commons.lang3` package in the Apache Commons Lang library. This library provides a set of utility classes and methods for common tasks in Java programming.