Java tutorial
//package com.java2s; public class Main { public static String getUrlFileName(String url) { int slashIndex = url.lastIndexOf('/'); int dotIndex = url.lastIndexOf('.'); String filenameWithoutExtension; if (dotIndex == -1) { filenameWithoutExtension = url.substring(slashIndex + 1); } else { filenameWithoutExtension = url.substring(slashIndex + 1, dotIndex); } return filenameWithoutExtension; } }