Java tutorial
//package com.java2s; //License from project: Open Source License import android.text.TextUtils; public class Main { private static String getFileName(String fileName) { if (!TextUtils.isEmpty(fileName)) { int fragment = fileName.lastIndexOf('#'); if (fragment > 0) { fileName = fileName.substring(0, fragment); } int query = fileName.lastIndexOf('?'); if (query > 0) { fileName = fileName.substring(0, query); } return fileName; } else { return ""; } } }