List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getFileExt(String fileName) { int index = fileName.lastIndexOf(".") + 1; String ext = fileName.substring(index, fileName.length()); return ext;/*from w w w .j a va 2 s. c om*/ }
From source file:Main.java
public static Long getTwitterIdFromUrl(String sourceUrl) { String id = sourceUrl.replaceFirst("#!/", ""); int index = id.lastIndexOf("/"); if (index > 0) { index++;/*from w w w . j a v a 2 s.c om*/ try { return Long.parseLong(id.substring(index)); } catch (NumberFormatException ex) { } } return null; }
From source file:com.ery.server.zk.ZKAssign.java
public static String getNodeName(ZooKeeperWatcher zkw, String path) { return path.substring(path.lastIndexOf("/") + 1); }
From source file:Main.java
private static String getSimpleName(String generatorClassFqName) { return generatorClassFqName.substring(generatorClassFqName.lastIndexOf(".") + 1); }
From source file:com.mirth.connect.util.AttachmentUtil.java
public static void writeToFile(String filePath, Attachment attachment, boolean binary) throws IOException { File file = new File(filePath); if (!file.canWrite()) { String dirName = file.getPath(); int i = dirName.lastIndexOf(File.separator); if (i > -1) { dirName = dirName.substring(0, i); File dir = new File(dirName); dir.mkdirs();//from w w w. j av a 2 s .c o m } file.createNewFile(); } if (attachment != null && StringUtils.isNotEmpty(filePath)) { FileUtils.writeByteArrayToFile(file, binary ? Base64Util.decodeBase64(attachment.getContent()) : attachment.getContent()); } }
From source file:Main.java
/** * Convenience method for retrieving a subset of the UIDefaults pertaining * to a particular class./*from w ww . java 2s . c o m*/ * * @param clazz the class of interest * @return the UIDefaults of the class */ public static UIDefaults getUIDefaultsOfClass(Class clazz) { String name = clazz.getName(); name = name.substring(name.lastIndexOf(".") + 2); return getUIDefaultsOfClass(name); }
From source file:Main.java
/** * Get the main name of specified file/*from w w w .j a v a 2 s. co m*/ * * @param p_absoluteFilename * The file name with absolute path * @return String Main name of file * * @version 1.0 * @since 8.2.2 */ private static String getMainFilename(String p_absoluteFilename) { return p_absoluteFilename.substring(p_absoluteFilename.lastIndexOf(File.separator) + 1); }
From source file:ShowClass.java
public static String typeName(Class t) { String brackets = ""; while (t.isArray()) { brackets += "[]"; t = t.getComponentType();//from w w w.j a va 2s. c o m } String name = t.getName(); int pos = name.lastIndexOf('.'); if (pos != -1) name = name.substring(pos + 1); return name + brackets; }
From source file:Main.java
public static String resolveFileNameForPath(String filePath) { int index = 0; String fileName = ""; if ((index = filePath.lastIndexOf("/")) != -1) fileName = filePath.substring(index + 1); return fileName.contains(".") ? fileName : ""; }
From source file:Main.java
public static boolean hasParameter(String url, String name) { int index = url.lastIndexOf('/') + 1; if (index == -1 || index >= url.length()) { return false; }/*from w ww. ja va2 s . c o m*/ index = url.indexOf('?', index); while (index != -1) { int start = index + 1; if (start >= url.length()) { return false; } int eqIndex = url.indexOf('=', start); if (eqIndex == -1) { return false; } if (url.substring(start, eqIndex).equals(name)) { return true; } index = url.indexOf('&', start); } return false; }