Java URL to Path getPathParts(String url)

Here you can find the source of getPathParts(String url)

Description

get Path Parts

License

Open Source License

Declaration

public static List<String> getPathParts(String url) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.net.MalformedURLException;
import java.net.URL;

import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;

public class Main {
    public static List<String> getPathParts(String url) {
        return Arrays.asList(getPath(url).split(Pattern.quote("/")));

    }//from w ww .  ja va  2s  . c o m

    public static String getPath(String url) {
        try {
            URL tempUrl = new URL(url);
            return tempUrl.getPath();
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("The url " + url + " is not valid.");
        }
    }
}

Related

  1. getPath(String urlString)
  2. getPath(URL theURL)
  3. getPath(URL url)
  4. getPath(URL url)
  5. getPathFromURL(final String url)