List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getFilenameExtension(String path) { if (path == null) { return null; }/* w ww . j ava2 s . co m*/ int sepIndex = path.lastIndexOf("."); return (sepIndex != -1 ? path.substring(sepIndex + 1) : null); }
From source file:Main.java
private static String getFileNameNoEx(String filename) { if (filename != null && filename.length() > 0) { int dot = filename.lastIndexOf('.'); if ((dot > -1) && (dot < (filename.length()))) { return filename.substring(0, dot); }//from www . j a v a 2s .co m } return filename; }
From source file:Main.java
public static String getFileExtension(String url) { if ((url != null) && (url.indexOf('.') != -1)) { return url.substring(url.lastIndexOf('.') + 1); }//from www . j a v a2 s .co m return ""; }
From source file:Main.java
public static String getFileExtensionName(String fileName) { String extensionName = ""; if (!isEmpty(fileName) && fileName.lastIndexOf(".") >= 0) { extensionName = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); }//from w w w . j a v a2 s .c o m return extensionName; }
From source file:com.spotify.styx.model.WorkflowInstance.java
public static WorkflowInstance parseKey(String key) { final int lastHashPos = key.lastIndexOf('#'); if (lastHashPos < 1) { throw new IllegalArgumentException("Key must contain a hash '#' sign on position > 0"); }/* www. j a v a 2s .c om*/ final WorkflowId workflowId = WorkflowId.parseKey(key.substring(0, lastHashPos)); return create(workflowId, key.substring(lastHashPos + 1)); }
From source file:jfs.sync.base.AbstractJFSFileProducerFactory.java
public static final String[] getPathAndName(String relativePath, String separator) { String[] result = new String[2]; String name = relativePath; int idx = name.lastIndexOf(separator); String parentPath = ""; if (idx >= 0) { parentPath = name.substring(0, idx); idx++;/* ww w .jav a2 s .com*/ name = name.substring(idx); } // if if (LOG.isDebugEnabled()) { LOG.debug("getPathAndName(" + relativePath + ") " + parentPath + ";" + name); } // if result[0] = parentPath; result[1] = name; return result; }
From source file:Main.java
public static String trimExtension(String filename) { if ((filename != null) && (filename.length() > 0)) { int i = filename.lastIndexOf('.'); if ((i > -1) && (i < (filename.length()))) { return filename.substring(0, i); }/* ww w . jav a 2s . c om*/ } return filename; }
From source file:Main.java
public static String getFileName(String path) { if (path == null) { return ""; }/*w w w . j a v a 2s.c o m*/ int i = path.lastIndexOf("\\"); if (i < 0) { i = path.lastIndexOf("/"); } if (i < 0) { return path; } return path.substring(i + 1); }
From source file:cn.vlabs.clb.api.io.FileUtil.java
public static String getSuffix(String filename) { int pos = filename.lastIndexOf('.'); if (pos != -1) { return ""; } else {//from w w w. jav a 2 s. co m return filename.substring(pos); } }
From source file:Main.java
public static String toDescName(String className) { int arrCount = className.lastIndexOf('[') + 1; if (arrCount > 0) { className = className.substring(arrCount); }//from w ww . ja v a 2 s. com if (className.length() == 1) { switch (className.charAt(0)) { case 'Z': className = "boolean"; break; case 'B': className = "byte"; break; case 'C': className = "char"; break; case 'S': className = "short"; break; case 'I': className = "int"; break; case 'J': className = "long"; break; case 'F': className = "float"; break; case 'D': className = "double"; break; } } for (int i = 0; i < arrCount; ++i) { className += "[]"; } return className; }