List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getFileName(String pathandname) { int start = pathandname.lastIndexOf("/"); int end = pathandname.lastIndexOf("."); if (start != -1 && end != -1) { return pathandname.substring(start + 1, end); } else {/* w w w . j a va2 s . c o m*/ return null; } }
From source file:Main.java
/** * Returns a file path corresponding to a potential SMAP input * for the given compilation input (JSP file). *//*from www . j a v a2s. c o m*/ private static String inputSmapPath(String path) { return path.substring(0, path.lastIndexOf('.') + 1) + "smap"; }
From source file:Main.java
/** * Compute the parent of a path. Note : path must lead to an element. * /*w ww . j a v a2 s . c o m*/ * @param path the path with at least one slash, eg "./elem". * @return the parent of path, eg ".". */ public final static String parentOf(String path) { return path.substring(0, path.lastIndexOf('/')); }
From source file:Main.java
/** * get the last part of the zk-path//from www . j ava 2 s. com * @param path * @return */ public static String getZkName(String path) { return path.substring(path.lastIndexOf('/') + 1); }
From source file:Main.java
public static String getImagePath(String imageUrl) { int lastSlashIndex = imageUrl.lastIndexOf("/"); String imageName = imageUrl.substring(lastSlashIndex + 1); String imageDir = Environment.getExternalStorageDirectory().getPath() + "/university/pics"; File file = new File(imageDir); if (!file.exists()) { file.mkdirs();/* w w w .j a va 2 s . co m*/ } String imagePath = imageDir + "/" + imageName; return imagePath; }
From source file:Main.java
/** * Returns the filename without path and without extension. * /*from w w w . ja v a2 s .co m*/ * @param fileName * @return the file name without extension and path */ public static String basename(final String fileName) { int dot = fileName.lastIndexOf('.'); int sep = fileName.lastIndexOf(File.separatorChar); if (sep == -1) { sep = fileName.lastIndexOf('\\'); } if (dot == -1) { dot = fileName.length(); } return fileName.substring(sep + 1, dot); }
From source file:Main.java
public static String getFileExt(File file) { String fileName = file.getName(); int i = fileName.lastIndexOf('.'); if (i < 0) { return null; }/*from w ww . ja v a 2 s .c om*/ return fileName.substring(i); }
From source file:Main.java
public static String substringAfterLast(String f, String str) { int idx = f.lastIndexOf(str); if (-1 != idx) { return f.substring(idx + str.length()); }//from ww w. j a va 2 s . c om return null; }
From source file:Main.java
@SuppressWarnings("unused") public static String getFileExtension(String path) { return path == null ? null : path.substring(path.lastIndexOf(".") + 1); }
From source file:FileUtil.java
public static String StripFileExtension(String fileName) { return fileName.substring(0, fileName.lastIndexOf('.')); }