I have several strings that are being combined to make a URI. I want to ensure that the resulting URI is as simple as possible. For example, given
str1 = "/dir1/dir2";
str2 = "./dir3/";
I want to end up with "/dir1/dir2/dir3/" not "/dir1/dir2/./dir3/".
Is there a Java library that performs this kind of simplification?
JDK7 has a Path.normalize method which removes redundant name elements from a path. It also contains Path.resolve which can be used to join two paths.
Take a look at the Java Tutorial | Path Operations for more information.