Here you can find the source of getFilePart(String uri)
public static String getFilePart(String uri)
//package com.java2s; //License from project: GNU General Public License import java.net.URI; public class Main { public static String getFilePart(String uri) { try {// w w w . j a v a 2 s. c o m URI u = URI.create(uri); uri = u.getPath(); } catch (Exception e) { return "http://invalid/uri/"; } //if(uri.length() == 0) return int begin = uri.lastIndexOf("/"); int end = uri.lastIndexOf("."); if (end == -1 || begin > end) end = uri.length(); return uri.substring(begin + 1, end); } }