我能想到的最短的代码段是这样的:
URI uri = new URI("http://www.stackoverflow.com/path/to/something");URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve(".")
我能想到的最短的代码段是这样的:
URI uri = new URI("http://www.stackoverflow.com/path/to/something");URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve(".")