Here you can find the source of getPathParts(String url)
public static List<String> getPathParts(String url)
//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."); } } }