Java Utililty Methods URL to Path

List of utility methods to do URL to Path

Description

The list of methods to do URL to Path are organized into topic(s).

Method

StringgetPath(String url)
get Path
try {
    URL tempUrl = new URL(url);
    return tempUrl.getPath();
} catch (MalformedURLException e) {
    throw new IllegalArgumentException("The url " + url + " is not valid.");
StringgetPath(String urlString)
get Path
try {
    URL url = new URL(urlString);
    return url.getPath();
} catch (MalformedURLException e) {
    throw e;
StringgetPath(URL theURL)
get Path
String file = theURL.getFile();
String path = null;
if (file != null) {
    int q = file.lastIndexOf('?');
    if (q != -1) {
        path = file.substring(0, q);
    } else {
        path = file;
...
StringgetPath(URL url)
get Path
return new File(url.getFile()).getPath();
StringgetPath(URL url)
get Path
try {
    return url.toURI().getSchemeSpecificPart();
} catch (URISyntaxException use) {
    return url.getPath();
StringgetPathFromURL(final String url)
get Path From URL
URL urlObj = new URL(url);
return urlObj.getPath();
ListgetPathParts(String url)
get Path Parts
return Arrays.asList(getPath(url).split(Pattern.quote("/")));