List of usage examples for java.lang String lastIndexOf
public int lastIndexOf(String str)
From source file:Main.java
public static String getFileExtension(String filename) { String extension = ""; if (filename != null) { int dotPos = filename.lastIndexOf("."); if (dotPos >= 0 && dotPos < filename.length() - 1) { extension = filename.substring(dotPos + 1); }/*from w ww . ja v a2s. co m*/ } return extension.toLowerCase(); }
From source file:Main.java
public static void createDipPath(String file) { String parentFile = file.substring(0, file.lastIndexOf("/")); File file1 = new File(file); File parent = new File(parentFile); if (!file1.exists()) { parent.mkdirs();/*from w w w .j a v a 2s. co m*/ try { file1.createNewFile(); } catch (IOException e) { } } }
From source file:Main.java
/** * Compute the namespace prefix of a qualified name. NOTE : this also works if qName is a path, * eg "./office:body/office:text"./*from ww w .ja v a 2s. com*/ * * @param qName a qualified name, eg "office:text". * @return the prefix or <code>null</code> if there's none, eg "office". */ public final static String namespace(String qName) { qName = basename(qName); final int colonIndex = qName.lastIndexOf(':'); if (colonIndex < 0) return null; else return qName.substring(0, colonIndex); }
From source file:Main.java
private static String getFileName(String fileName) { if (!TextUtils.isEmpty(fileName)) { int fragment = fileName.lastIndexOf('#'); if (fragment > 0) { fileName = fileName.substring(0, fragment); }//from w ww . j a v a 2 s .c om int query = fileName.lastIndexOf('?'); if (query > 0) { fileName = fileName.substring(0, query); } return fileName; } else { return ""; } }
From source file:Main.java
public static String authorNameFileAs(String name) { if (name == null || name.length() == 0) return name; int lastSpace = name.lastIndexOf(' '); if (lastSpace >= 0 && lastSpace < name.length() - 1) return name.substring(lastSpace + 1) + " " + name.substring(0, lastSpace); return name;/* w w w .j av a 2s .c om*/ }
From source file:Main.java
public static int getThreadNumber(int maxThreads) { if (maxThreads == 1) { return 1; } else {/* w w w .j av a 2 s . c o m*/ int threadNumber = 1; String name = Thread.currentThread().getName(); int lastIndex = name.lastIndexOf("-"); if (lastIndex >= 0) { try { threadNumber = Integer.parseInt(name.substring(lastIndex + 1)); } catch (NumberFormatException e) { } } return threadNumber; } }
From source file:Main.java
public static String getSimpleName(String fileName) { String str = fileName; if (str == null) { return null; }//from w ww. j ava 2s .c o m if (str.lastIndexOf(File.separator) >= 0) { str = str.substring(str.lastIndexOf(File.separator) + 1); } if (str.indexOf(".") >= 0) { str = str.substring(0, str.lastIndexOf(".")); } return str; }
From source file:asciidoc.maven.plugin.tools.FileHelper.java
public static String getFileExtension(File _file) { String name = _file.getName(); int k = name.lastIndexOf("."); String ext = ""; if (k != -1)//ww w .j a v a 2 s. c om ext = name.substring(k + 1, name.length()); return ext; }
From source file:com.hubrick.raml.mojo.util.JavaNames.java
public static String classNameOfPath(String path) { return path.substring(0, path.lastIndexOf(".")).replaceAll(File.separator, "."); }
From source file:Main.java
private static String getClassName(Object obj) { String fullPathClassName = obj.getClass().getName(); String className = fullPathClassName.substring(fullPathClassName.lastIndexOf(".") + 1, fullPathClassName.length()); return className; }