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 getClassName(Class c) {
    String className = c.getName();
    int firstChar;
    firstChar = className.lastIndexOf('.') + 1;
    if (firstChar > 0) {
        className = className.substring(firstChar);
    }/* w  ww. j av a  2s.c o m*/
    return className;
}

From source file:Main.java

private static String getFileName(String path) {
    int index = path.lastIndexOf("/");
    String fileName = path.substring(index + 1);
    return fileName;
}

From source file:Main.java

private static String getSimpleClassName(String name) {
    int lastIndex = name.lastIndexOf(".");
    return name.substring(lastIndex + 1);
}

From source file:Main.java

private static String getExtension(String path) {
    int dot = path.lastIndexOf('.');
    if (dot == -1) {
        return "";
    }//from www.ja v a  2  s  .  c  om
    return path.substring(dot);
}

From source file:Main.java

public static String getPathName(String path) {
    int index = path.lastIndexOf('/');
    if (index == -1 || index == 0)
        return path;
    return path.substring(index + 1);
}

From source file:Main.java

public static String returnSuffix(String fileName) {

    if (fileName.lastIndexOf(".") > 0) {
        String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
        return fileSuffix;
    }/*from w  w  w  . j a va 2s. c  o  m*/
    return null;
}

From source file:Main.java

private static String urlToFileName(String url) {
    int pos = url.lastIndexOf("/");
    if (pos < 0)
        pos = 0;//  w ww . jav a  2s  . c  om
    else
        pos += 1;
    return url.substring(pos);
}

From source file:Main.java

public static String getFileExtensionFromUrl(String url) {
    int dotPos = url.lastIndexOf('.');
    if (0 <= dotPos) {
        return (url.substring(dotPos + 1)).toLowerCase();
    }/*from ww  w  . j  a v  a  2s.c o m*/
    return "";
}

From source file:Main.java

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

From source file:Main.java

public static String getFileName(String url) {
    return url.substring(url.lastIndexOf('/') + 1, url.length());
}