Issue
In Objective-C I use -[NSURL URLByDeletingLastPathComponent]
to get parent URL. What's the equivalent of this in Java?
Solution
Shortest snippet of code I can think of is this:
URI uri = new URI("http://www.stackoverflow.com/path/to/something");
URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve(".");
Answered By - ɲeuroburɳ
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)