Here you can find the source of getFileName(URL url)
Parameter | Description |
---|---|
url | the url to get the filename out of |
public static String getFileName(URL url)
//package com.java2s; //License from project: LGPL import java.net.URL; public class Main { /**/*from ww w .jav a 2s. c o m*/ * Returns the file name (without the path) of the resource specified * by the given url. * @param url the url to get the filename out of * @return String containing the name of the file, zero-length if none */ public static String getFileName(URL url) { return url.getPath().substring(stripResource(url.getPath()).length()); } /** * returns the resource path without the resource. * @param path the path to the resource * @return path without the resource itself */ public static String stripResource(String path) { String result = null; if (path != null) { int pos = path.lastIndexOf("/"); result = path.substring(0, pos + 1); } return result; } }