Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**
     *  get file name form url 
     * @param url
     * @return
     */
    public static String getFileNameFromURL(String url) {
        int length = url.length();
        int lastIndex = 0;
        if (url.contains("/")) {
            lastIndex = url.lastIndexOf("/");
        } else if (url.contains("\"")) {
            lastIndex = url.lastIndexOf("\"");
        }
        return url.substring(lastIndex, length - lastIndex);
    }
}