Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * get file name form url * @param url * @return */ public static String getFileNameFromURL(String url) { int length = url.length(); int lastIndex = 0; if (url.contains("/")) { lastIndex = url.lastIndexOf("/"); } else if (url.contains("\"")) { lastIndex = url.lastIndexOf("\""); } return url.substring(lastIndex, length - lastIndex); } }