Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.text.TextUtils;

public class Main {

    public static String getFileName(String filePathName) {
        if (!TextUtils.isEmpty(filePathName)) {
            int index = filePathName.lastIndexOf('/');
            if (index != -1 && (index + 1) < filePathName.length()) {
                String name = filePathName.substring(index + 1);
                if (!TextUtils.isEmpty(name)) {
                    int subIndex = name.lastIndexOf(".");
                    if (subIndex != -1) {
                        return name.substring(0, subIndex);
                    }
                }
                return name;
            }
        }
        return "";
    }

    public static boolean isEmpty(String str) {
        if (str == null) {
            return true;
        }
        for (int i = 0, length = str.length(); i < length; i++) {
            if (!Character.isWhitespace(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }
}