Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getFilenameFromPath(String path) {
        if (path == null) {
            throw new IllegalArgumentException("path cannot be null");
        }
        int lastIndexOf = path.lastIndexOf("/");
        if (lastIndexOf == -1) {
            return path;
        }
        return path.substring(lastIndexOf + 1, path.length());
    }
}