Example usage for java.lang String lastIndexOf

List of usage examples for java.lang String lastIndexOf

Introduction

In this page you can find the example usage for java.lang String lastIndexOf.

Prototype

public int lastIndexOf(String str) 

Source Link

Document

Returns the index within this string of the last occurrence of the specified substring.

Usage

From source file:Main.java

public static String getFileExt(String filePath) {
    int pos = filePath.lastIndexOf(".");
    if (pos == -1)
        return "";
    return filePath.substring(pos + 1).toLowerCase();
}

From source file:Main.java

public static String getFileNameFromUrl(String url) {
    return url.substring(url.lastIndexOf("/"), url.length());
}

From source file:Main.java

public static String dirPath(String filePath) {
    int pos = filePath.lastIndexOf("/");
    if (pos < 0)
        return filePath;
    return filePath.substring(0, pos + 1);
}

From source file:Main.java

public static String getFileName(String str) {
    int index = str.lastIndexOf("/");
    if (index > 0) {
        return str.substring(index + 1);
    }/*from w w  w.  java2 s  .co  m*/
    return str;
}

From source file:Main.java

private static String makeFileSuffix(String url) {
    int index = url.lastIndexOf(".");
    if (index < 0) {
        return null;
    }/*from   www . ja  va2 s . c o m*/
    return url.substring(index + 1);
}

From source file:Main.java

private static String getFileExt(String filePath) {
    int pos = filePath.lastIndexOf(".");
    if (pos == -1)
        return "";
    return filePath.substring(pos + 1).toLowerCase();
}

From source file:Main.java

public static String getNameFromFileName(String name) {
    int index = name.lastIndexOf(".");
    if (index != -1) {
        name = name.substring(0, index);
    }/*  w ww  . j av  a2 s .c  om*/
    return name;
}

From source file:Main.java

public static String getUrlFileName(String url) {
    return url.substring(url.lastIndexOf("/") + 1);
}

From source file:Main.java

public static String lastName(String xpath) {
    int start = xpath.lastIndexOf("/");
    if (start == -1) {
        start = 0;//from  ww w . j  av  a 2 s.co  m
    }
    return xpath.substring(start, xpath.length());
}

From source file:Main.java

public static String getFileName(String url) {
    int index = url.lastIndexOf("/");
    if (index == -1 || index == url.length() - 1) {
        return url;
    } else {/*  w  ww .j  av a 2  s . com*/
        return url.substring(index + 1);
    }
}