public static String getFileName(String url) throws MalformedURLException {
URL u = new URL(url);
String path = u.getPath();
if (path != null) {
String[] tokens = path.split("/");
return tokens[tokens.length - 1];
}
return null;
}
See also: Parsing a URL
No comments:
Post a Comment