String path = "/foo/bar//baz/"; String cleanedPath = StringUtils.cleanPath(path); System.out.println(cleanedPath); // Output: /foo/bar/baz
String basePath = "/foo/bar"; String relativePath = "../baz"; String resolvedPath = StringUtils.cleanPath(basePath + "/" + relativePath); System.out.println(resolvedPath); // Output: /foo/bazIn this example, we have a base path of "/foo/bar" and a relative path of "../baz", which means we want to go up one level and then go to the "baz" directory. The cleanPath method resolves this relative path based on the base path and returns the correct final path. The StringUtils class is part of the org.springframework.util package in the Spring Framework.