Java tutorial
//package com.java2s; public class Main { public static String getUrlFileName(String url) { if (url == null) { return null; } if (!isURL(url)) { return null; } if (!isFileUrl(url)) { return null; } String[] urlArr = url.split("/"); return urlArr[urlArr.length - 1]; } public static boolean isURL(String url) { if (url.startsWith("http://") || url.startsWith("https://")) { return true; } return false; } public static boolean isFileUrl(String url) { int lastIndex = url.lastIndexOf("/"); if (lastIndex < url.length() - 1) { return true; } return false; } }