Here you can find the source of getFileName(URL url)
Parameter | Description |
---|---|
url | to parse |
public static String getFileName(URL url)
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Reader; import java.net.URL; import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import net.sf.json.JSON; import net.sf.json.JSONObject; import org.apache.log4j.Logger; public class Main{ /**/*from ww w.j a v a 2s. c om*/ * returns the last element of the URL's path * * @param url to parse * @return the last element of the URL's path */ public static String getFileName(URL url) { String[] pathElements = url.getPath().split("/"); return pathElements[pathElements.length - 1]; } }