Here you can find the source of getFilename(final URL url, int maxLength)
public static String getFilename(final URL url, int maxLength) throws Exception
//package com.java2s; //License from project: Open Source License import java.net.URL; public class Main { public static String getFilename(final URL url, int maxLength) throws Exception { String filename = url.toString(); int index = filename.lastIndexOf('/'); if (index >= 0) { filename = filename.substring(index + 1); }//from ww w .jav a2s . co m if (maxLength > 0 && filename.length() > maxLength) { filename = filename.substring(filename.length() - maxLength); } return filename; } public static String getFilename(final URL url) throws Exception { return getFilename(url, -1); } }