Java URL to File Name getFileName(URL url)

Here you can find the source of getFileName(URL url)

Description

returns the last element of the URL's path

License

Open Source License

Parameter

Parameter Description
url to parse

Return

the last element of the URL's path

Declaration

public static String getFileName(URL url) 

Method Source Code

//package com.java2s;

import java.net.URL;

public class Main {
    /**/*from  w w w .  j a v  a  2s  .  c  o  m*/
     * returns the last element of the URL's path
     *
     * @param url to parse
     * @return the last element of the URL's path
     */
    public static String getFileName(URL url) {
        String[] pathElements = url.getPath().split("/");
        return pathElements[pathElements.length - 1];
    }
}

Related

  1. getFilename(String urlString)
  2. getFileName(URL extUrl)
  3. getFileName(URL url)
  4. getFileName(URL url)
  5. getFileName(URL url)
  6. getFileName(URL url)
  7. getFileName(URLConnection urlC)
  8. getFileName2(String url)
  9. getFileNameArray(String url)