List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getKey(String downloadUrl) { return downloadUrl.substring(downloadUrl.lastIndexOf("/") + 1, downloadUrl.lastIndexOf(".")); }
From source file:Main.java
/** * Extracts module name from component name (i.e. the "/" separated prefix) *//*w w w .j a v a 2 s.c o m*/ public static String moduleOf(String componentName) { int p = componentName.lastIndexOf('/'); if (p >= 0) { return componentName.substring(0, p); } return null; }
From source file:Main.java
public static boolean hasExtension(String filename) { int index = filename.lastIndexOf("."); if (index > -1) { String extension = filename.substring(index + 1).toLowerCase(); for (String accept : ACCEPTS_IMAGE) { if (accept.equals(extension)) { return true; }/*from w w w . ja v a 2 s. co m*/ } } return false; }
From source file:Main.java
public static String getFIleNameFromUrl(String url) { try {/*from w ww . jav a 2 s. co m*/ int tmp = url.lastIndexOf("/"); return url.substring(tmp + 1, url.length()); } catch (Exception ex) { return ""; } }
From source file:Main.java
/** * Returns the final word characters after the last '.' *//*from www . ja v a 2s .c o m*/ public static String getFileExtension(String file) { int index = file.lastIndexOf('.'); String extension = ""; if (index > 0) { extension = file.substring(index + 1); if (!extension.matches("\\w+")) { extension = ""; } } return extension; }
From source file:Main.java
private static String getClassName(String pkgName, String fileName) { int endIndex = fileName.lastIndexOf("."); String clazz = null;/* w ww.j a v a2 s. c o m*/ if (endIndex >= 0) { clazz = fileName.substring(0, endIndex); } String clazzName = null; if (clazz != null) { clazzName = pkgName + "." + clazz; } return clazzName; }
From source file:Main.java
public static String getExtension(String inputString) { return inputString.substring(inputString.lastIndexOf(".") + 1); }
From source file:Main.java
/** * Extracts the component simple name from the fully qualified component * name. This is simply the part following the last "/". *///from w w w . j a v a 2 s . co m public static String simpleName(String componentName) { int p = componentName.lastIndexOf('/'); if (p >= 0) { return componentName.substring(p + 1); } return null; }
From source file:Main.java
public static String getPath(String path) { int la = path.lastIndexOf(separator); String subPath = path.substring(0, la); return subPath; }
From source file:Main.java
public static String extractFileName(String fullFileName) { return fullFileName.substring(fullFileName.lastIndexOf("/") + 1, fullFileName.length()); }