List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:io.fluo.webindex.data.Copy.java
public static String getFilename(String fullPath) { int slashIndex = fullPath.lastIndexOf("/"); if (slashIndex == -1) { return fullPath; }//w w w . j av a 2 s .c o m return fullPath.substring(slashIndex + 1); }
From source file:Main.java
private static String removeLast(String s, String g) { if (s.contains(g)) { int index = s.lastIndexOf(g); int indexEnd = index + g.length(); if (index == 0) return s.substring(1); else if (index == s.length() - 1) return s.substring(0, index); else// w ww. j a v a 2s.com return s.substring(0, index) + s.substring(indexEnd); } return s; }
From source file:Utils.java
/** * Create a unique directory within a directory 'root' * //from w w w .j a va 2s. c o m * @param rootDir * @param seed * @return unique directory * @throws IOException */ public static synchronized File createUniqueDirectory(File rootDir, String seed) throws IOException { int index = seed.lastIndexOf('.'); if (index > 0) { seed = seed.substring(0, index); } File result = null; int count = 0; while (result == null) { String name = seed + "." + count + ".tmp"; File file = new File(rootDir, name); if (!file.exists()) { file.mkdirs(); result = file; } count++; } return result; }
From source file:com.icesoft.applications.faces.auctionMonitor.AddAuctionItem.java
public static String getPictureName(String fileName) { int index = fileName.lastIndexOf('.'); return (fileName.substring(0, index) + ".jpg"); }
From source file:Main.java
public static String getExtensionFromFileName(String fileName) { String extension = null;/* w ww . j a v a2 s . co m*/ int i = fileName.lastIndexOf('.'); if (i > 0) { extension = fileName.substring(i + 1); } return extension; }
From source file:Main.java
public static String constructMediaPath(String formFilePath) { String pathNoExtension = formFilePath.substring(0, formFilePath.lastIndexOf(".")); return pathNoExtension + "-media"; }
From source file:Main.java
public static int toPathLsatIndex(String fileName) { int point = fileName.lastIndexOf('/'); if (point == -1) { point = fileName.lastIndexOf('\\'); }/*from w w w. ja v a 2 s.c om*/ return point; }
From source file:Main.java
public static String nameWithoutNS(String tag) { if (tag == null) return null; int i = tag.lastIndexOf(":"); if (i > 0) { return tag.substring(i + 1); } else {/*from ww w . j a v a 2 s . c om*/ return tag; } }
From source file:Main.java
public static File getFile(String path) throws IOException { String dirPath = path.substring(0, path.lastIndexOf(File.separator)); File dirFile = new File(dirPath); File file = new File(path); if (!dirFile.exists()) dirFile.mkdirs();/*from w w w . j av a 2 s . c om*/ if (!file.exists()) file.createNewFile(); return file; }
From source file:de.arraying.arraybot.util.UScript.java
/** * Gets the ID part of a URL.//from w ww .ja v a 2 s. c o m * @param url The URL (MUST be a valid URL) * @return The ID. */ public static String getID(String url) { return url.substring(url.lastIndexOf('/')); }