Java URL to Path getPath(String url)

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

Description

get Path

License

Open Source License

Declaration

public static String getPath(String url) 

Method Source Code


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

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

public class Main {
    public static String getPath(String url) {
        try {//from w  ww.j a v  a 2 s .co  m
            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)