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 getDownloadFileName(String downloadURL) {
    int index = downloadURL.lastIndexOf("/") + 1;
    String fileName = downloadURL.substring(index);
    return fileName;
}

From source file:Main.java

public static String getTitle(String url) {
    int idx = url.lastIndexOf(".");
    int slant = url.lastIndexOf("/");
    if (idx < 0)
        idx = url.length();/*from   w w  w  .ja v  a 2 s . c o m*/
    if (slant < 0)
        slant = 0;
    String title = url.substring(slant, idx);
    return title;
}

From source file:Main.java

public static boolean hasExtentsion(String filename) {
    int dot = filename.lastIndexOf('.');
    if ((dot > -1) && (dot < (filename.length() - 1))) {
        return true;
    } else {//w w w.  j  a v  a 2 s  .  co  m
        return false;
    }
}

From source file:Main.java

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

From source file:Main.java

public static String getFileName(String url) {
    return url.substring(url.lastIndexOf(File.separator) + 1, url.lastIndexOf("."));
}

From source file:Main.java

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

From source file:Main.java

private static String getDir(String fullfile) {
    int index = fullfile.lastIndexOf("/");
    if (index > 0 && index < fullfile.length()) {
        return fullfile.substring(0, index);
    }//  ww w .  jav a 2  s. c  om
    return null;
}

From source file:Main.java

protected static String getDirPath(String dir) {
    int index = dir.lastIndexOf("/");
    String path;//from w  ww.ja  v a 2 s  .c  o  m
    if (index > 0) {
        path = dir.substring(0, index);
    } else {
        path = "";
    }
    return path;
}

From source file:Main.java

public static String getFileName(String path) {
    int start = path.lastIndexOf("/");
    int end = path.lastIndexOf(".");
    if (start != -1 && end != -1) {
        return path.substring(start + 1, end);
    } else {/*from ww w . java2  s  .  co  m*/
        return null;
    }
}

From source file:Main.java

public static String clearDirectory(String str) {
    int i = str.lastIndexOf(File.separator);
    if (i != -1) {
        return clearSuffix(str.substring(i + 1, str.length()));
    }/* ww  w .j a  v  a  2  s.  c  o m*/
    return str;
}