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 b64FileName(String fn) {
    String fln = fn.substring(fn.lastIndexOf('/') + 1);
    fln = fln.substring(0, fln.indexOf('.'));
    return fln + B64EX;
}

From source file:Main.java

public static String getFileExt(String fileName) {
    int i = fileName.lastIndexOf('.');
    if (i < 0) {
        return null;
    }//from ww w.j  a  va2  s .  com
    return fileName.substring(i);
}

From source file:Main.java

public static String getExtension(String fileName) {
    return fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
}

From source file:Main.java

public static String getExtensionFromFileName(String fileName) {
    int slash = fileName.lastIndexOf(File.separatorChar);
    int dot = fileName.lastIndexOf('.');
    if (slash >= dot) {
        return null;
    }//from  w  ww  . j ava2 s .c o m
    String extension = fileName.substring(dot + 1).toLowerCase(Locale.ENGLISH);
    return extension;
}

From source file:Main.java

public static String getFileExtension(String filename) {
    return filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
}

From source file:Main.java

private static String getShortName(final String name) {
    int n = name.lastIndexOf('/');
    return n == -1 ? name : "o";
}

From source file:Main.java

private static String removeLastSegment(final String fqcn) {
    return fqcn.substring(0, fqcn.lastIndexOf("."));
}

From source file:Main.java

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

From source file:Main.java

public static String extractPackageName(String className) {
    int lastPoint = className.lastIndexOf(".");
    if (lastPoint >= 0) {
        return className.substring(0, lastPoint);
    } else {/*from w  w w .  j  ava 2 s  .c  om*/
        return "";
    }
}

From source file:Main.java

public static int convertNameToColor(String name) {
    name = name.substring(0, name.lastIndexOf('.'));
    return Color.parseColor(name);
}